Creating Excel Files with Python and Xlsxwriter

Creating Excel Files with Python and Xlsxwriter

Creating Excel files with Python and XlsxWriter Release 3.0.1 John McNamara August 10, 2021 CONTENTS 1 Introduction 3 2 Getting Started with XlsxWriter5 2.1 Installing XlsxWriter....................................5 2.2 Running a sample program................................6 2.3 Documentation.......................................7 3 Tutorial 1: Create a simple XLSX file9 4 Tutorial 2: Adding formatting to the XLSX File 13 5 Tutorial 3: Writing different types of data to the XLSX File 17 6 The Workbook Class 21 6.1 Constructor......................................... 21 6.2 workbook.add_worksheet()................................ 25 6.3 workbook.add_format().................................. 26 6.4 workbook.add_chart()................................... 27 6.5 workbook.add_chartsheet()................................ 28 6.6 workbook.close()...................................... 29 6.7 workbook.set_size().................................... 30 6.8 workbook.tab_ratio().................................... 30 6.9 workbook.set_properties()................................ 31 6.10 workbook.set_custom_property()............................ 33 6.11 workbook.define_name()................................. 35 6.12 workbook.add_vba_project()............................... 37 6.13 workbook.set_vba_name()................................ 37 6.14 workbook.worksheets().................................. 37 6.15 workbook.get_worksheet_by_name().......................... 38 6.16 workbook.get_default_url_format()............................ 38 6.17 workbook.set_calc_mode()................................ 38 6.18 workbook.use_zip64()................................... 39 6.19 workbook.read_only_recommended().......................... 39 7 The Worksheet Class 41 7.1 worksheet.write()..................................... 41 i 7.2 worksheet.add_write_handler().............................. 44 7.3 worksheet.write_string().................................. 45 7.4 worksheet.write_number()................................ 47 7.5 worksheet.write_formula()................................ 47 7.6 worksheet.write_array_formula()............................. 49 7.7 worksheet.write_dynamic_array_formula()....................... 50 7.8 worksheet.write_blank().................................. 51 7.9 worksheet.write_boolean()................................ 52 7.10 worksheet.write_datetime()................................ 52 7.11 worksheet.write_url()................................... 53 7.12 worksheet.write_rich_string()............................... 56 7.13 worksheet.write_row()................................... 58 7.14 worksheet.write_column()................................. 59 7.15 worksheet.set_row().................................... 60 7.16 worksheet.set_row_pixels()................................ 62 7.17 worksheet.set_column().................................. 62 7.18 worksheet.set_column_pixels().............................. 64 7.19 worksheet.insert_image()................................. 65 7.20 worksheet.insert_chart()................................. 69 7.21 worksheet.insert_textbox()................................ 71 7.22 worksheet.insert_button()................................. 73 7.23 worksheet.data_validation()................................ 75 7.24 worksheet.conditional_format().............................. 77 7.25 worksheet.add_table()................................... 79 7.26 worksheet.add_sparkline()................................ 79 7.27 worksheet.write_comment()............................... 81 7.28 worksheet.show_comments()............................... 83 7.29 worksheet.set_comments_author()........................... 83 7.30 worksheet.get_name().................................. 84 7.31 worksheet.activate().................................... 84 7.32 worksheet.select()..................................... 85 7.33 worksheet.hide()...................................... 85 7.34 worksheet.set_first_sheet()................................ 86 7.35 worksheet.merge_range()................................. 87 7.36 worksheet.autofilter()................................... 89 7.37 worksheet.filter_column()................................. 90 7.38 worksheet.filter_column_list()............................... 91 7.39 worksheet.set_selection()................................. 92 7.40 worksheet.freeze_panes()................................ 92 7.41 worksheet.split_panes().................................. 93 7.42 worksheet.set_zoom()................................... 94 7.43 worksheet.right_to_left()................................. 94 7.44 worksheet.hide_zero()................................... 95 7.45 worksheet.set_background()............................... 95 7.46 worksheet.set_tab_color()................................ 97 7.47 worksheet.protect().................................... 97 7.48 worksheet.unprotect_range()............................... 98 7.49 worksheet.set_default_row()............................... 99 ii 7.50 worksheet.outline_settings()............................... 99 7.51 worksheet.set_vba_name()................................ 100 7.52 worksheet.ignore_errors()................................. 100 8 The Worksheet Class (Page Setup) 103 8.1 worksheet.set_landscape()................................ 103 8.2 worksheet.set_portrait().................................. 103 8.3 worksheet.set_page_view()................................ 103 8.4 worksheet.set_paper().................................. 104 8.5 worksheet.center_horizontally()............................. 105 8.6 worksheet.center_vertically()............................... 105 8.7 worksheet.set_margins()................................. 105 8.8 worksheet.set_header().................................. 106 8.9 worksheet.set_footer().................................. 110 8.10 worksheet.repeat_rows()................................. 110 8.11 worksheet.repeat_columns()............................... 111 8.12 worksheet.hide_gridlines()................................ 111 8.13 worksheet.print_row_col_headers()........................... 112 8.14 worksheet.hide_row_col_headers()........................... 112 8.15 worksheet.print_area().................................. 113 8.16 worksheet.print_across()................................. 114 8.17 worksheet.fit_to_pages()................................. 114 8.18 worksheet.set_start_page()................................ 115 8.19 worksheet.set_print_scale()............................... 115 8.20 worksheet.set_h_pagebreaks().............................. 116 8.21 worksheet.set_v_pagebreaks().............................. 116 9 The Format Class 117 9.1 Creating and using a Format object........................... 117 9.2 Format Defaults...................................... 118 9.3 Modifying Formats..................................... 119 9.4 Number Format Categories................................ 119 9.5 Number Formats in different locales........................... 123 9.6 Format methods and Format properties......................... 125 9.7 format.set_font_name().................................. 126 9.8 format.set_font_size()................................... 127 9.9 format.set_font_color().................................. 127 9.10 format.set_bold()...................................... 128 9.11 format.set_italic()..................................... 129 9.12 format.set_underline()................................... 129 9.13 format.set_font_strikeout()................................ 130 9.14 format.set_font_script().................................. 131 9.15 format.set_num_format()................................. 131 9.16 format.set_locked().................................... 134 9.17 format.set_hidden().................................... 135 9.18 format.set_align()..................................... 135 9.19 format.set_center_across()................................ 137 9.20 format.set_text_wrap().................................. 138 iii 9.21 format.set_rotation().................................... 139 9.22 format.set_reading_order()................................ 140 9.23 format.set_indent().................................... 140 9.24 format.set_shrink()..................................... 141 9.25 format.set_text_justlast()................................. 142 9.26 format.set_pattern().................................... 142 9.27 format.set_bg_color()................................... 142 9.28 format.set_fg_color()................................... 143 9.29 format.set_border().................................... 143 9.30 format.set_bottom().................................... 144 9.31 format.set_top()...................................... 144 9.32 format.set_left()...................................... 145 9.33 format.set_right()..................................... 145 9.34 format.set_border_color()................................. 145 9.35 format.set_bottom_color()................................. 145 9.36 format.set_top_color()................................... 146 9.37 format.set_left_color()................................... 146 9.38 format.set_right_color().................................. 146 9.39 format.set_diag_border()................................. 146 9.40 format.set_diag_type().................................. 147 9.41 format.set_diag_color().................................. 147 10 The Chart Class 149 10.1 chart.add_series()..................................... 151 10.2 chart.set_x_axis()..................................... 153 10.3 chart.set_y_axis()....................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    673 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us