工作簿 xlsxwriter 的大小



我正在发送一个用xlsxwriter制作的 excel 文件作为 django 视图的响应,我想设置content-length标题,但我找不到类似.get_size()xlsxwriter.Workbook方法,在哪里获取工作簿大小的方法?

我刚刚遇到了类似的问题,试图查找工作表中的列数。 我刚刚找到了一种方法来完成我一直在寻找的东西,希望它也能解决您的问题。

如果您像普通一样创建 XLSX 工作表对象,然后调用dir(( 函数,它将显示所有对象属性的列表,如下所示:

print(worksheet.__dir__())
fh
escapes
internal_fh
name
index
str_table
palette
optimization
tmpdir
is_chartsheet
ext_sheets
fileclosed
excel_version
excel2003_style
xls_rowmax
xls_colmax
xls_strmax
dim_rowmin
dim_rowmax
dim_colmin
dim_colmax
colinfo
selections
hidden
active
tab_color
panes
active_pane
selected
page_setup_changed
paper_size
orientation
print_options_changed
hcenter
vcenter
print_gridlines
screen_gridlines
print_headers
header_footer_changed
header
footer
header_footer_aligns
header_footer_scales
header_images
footer_images
header_images_list
margin_left
margin_right
margin_top
margin_bottom
margin_header
margin_footer
repeat_row_range
repeat_col_range
print_area_range
page_order
black_white
draft_quality
print_comments
page_start
fit_page
fit_width
fit_height
hbreaks
vbreaks
protect_options
set_cols
set_rows
zoom
zoom_scale_normal
print_scale
is_right_to_left
show_zeros
leading_zeros
outline_row_level
outline_col_level
outline_style
outline_below
outline_right
outline_on
outline_changed
original_row_height
default_row_height
default_row_pixels
default_col_pixels
default_row_zeroed
names
write_match
table
merge
row_spans
has_vml
has_header_vml
has_comments
comments
comments_list
comments_author
comments_visible
vml_shape_id
buttons_list
vml_header_id
autofilter_area
autofilter_ref
filter_range
filter_on
filter_cols
filter_type
col_sizes
row_sizes
col_formats
col_size_changed
row_size_changed
last_shape_id
rel_count
hlink_count
hlink_refs
external_hyper_links
external_drawing_links
external_comment_links
external_vml_links
external_table_links
drawing_links
vml_drawing_links
charts
images
tables
sparklines
shapes
shape_hash
drawing
rstring
previous_row
validations
cond_formats
dxf_priority
page_view
vba_codename
date_1904
hyperlinks
strings_to_numbers
strings_to_urls
nan_inf_to_errors
strings_to_formulas
default_date_format
default_url_format
remove_timezone
row_data_filename
row_data_fh
worksheet_meta
vml_data_id
row_data_fh_closed
vertical_dpi
horizontal_dpi
__module__
__doc__
__init__
write
write_string
write_number
write_blank
write_formula
write_array_formula
write_datetime
write_boolean
write_url
write_rich_string
write_row
write_column
insert_image
insert_textbox
insert_chart
write_comment
show_comments
set_comments_author
get_name
activate
select
hide
set_first_sheet
set_column
set_row
set_default_row
merge_range
autofilter
filter_column
filter_column_list
data_validation
conditional_format
add_table
add_sparkline
set_selection
outline_settings
freeze_panes
split_panes
set_zoom
right_to_left
hide_zero
set_tab_color
protect
insert_button
set_landscape
set_portrait
set_page_view
set_paper
center_horizontally
center_vertically
set_margins
set_header
set_footer
repeat_rows
repeat_columns
hide_gridlines
print_row_col_headers
print_area
print_across
fit_to_pages
set_start_page
set_print_scale
set_h_pagebreaks
set_v_pagebreaks
set_vba_name
_initialize
_assemble_xml_file
_check_dimensions
_convert_date_time
_convert_name_area
_sort_pagebreaks
_extract_filter_tokens
_parse_filter_expression
_parse_filter_tokens
_encode_password
_prepare_image
_prepare_shape
_prepare_header_image
_prepare_chart
_position_object_emus
_position_object_pixels
_size_col
_size_row
_comment_params
_button_params
_prepare_vml_objects
_prepare_header_vml_objects
_prepare_tables
_table_function_to_formula
_set_spark_color
_get_range_data
_csv_join
_escape_url
_write_font
_write_underline
_write_vert_align
_write_rstring_color
_get_palette_color
_isnan
_isinf
_opt_close
_opt_reopen
_write_worksheet
_write_dimension
_write_sheet_views
_write_sheet_view
_write_sheet_format_pr
_write_cols
_write_col_info
_write_sheet_data
_write_optimized_sheet_data
_write_page_margins
_write_page_setup
_write_print_options
_write_header_footer
_write_odd_header
_write_odd_footer
_write_rows
_write_single_row
_calculate_spans
_write_row
_write_empty_row
_write_cell
_write_cell_value
_write_cell_array_formula
_write_sheet_pr
_write_page_set_up_pr
_write_tab_color
_write_outline_pr
_write_row_breaks
_write_col_breaks
_write_brk
_write_merge_cells
_write_merge_cell
_write_hyperlinks
_write_hyperlink_external
_write_hyperlink_internal
_write_auto_filter
_write_autofilters
_write_filter_column
_write_filters
_write_filter
_write_custom_filters
_write_custom_filter
_write_sheet_protection
_write_drawings
_write_drawing
_write_legacy_drawing
_write_legacy_drawing_hf
_write_data_validations
_write_data_validation
_write_formula_1
_write_formula_2
_write_conditional_formats
_write_conditional_formatting
_write_cf_rule
_write_formula
_write_color_scale
_write_data_bar
_write_cfvo
_write_color
_write_selections
_write_selection
_write_panes
_write_freeze_panes
_write_split_panes
_calculate_x_split_width
_write_table_parts
_write_table_part
_write_ext_sparklines
_write_sparklines
_write_ext
_write_sparkline_groups
_write_sparkline_group
_write_spark_color
_write_color_series
_write_color_negative
_write_color_axis
_write_color_markers
_write_color_first
_write_color_last
_write_color_high
_write_color_low
_write_phonetic_pr
_set_filehandle
_set_xml_writer
_xml_close
_xml_declaration
_xml_start_tag
_xml_start_tag_unencoded
_xml_end_tag
_xml_empty_tag
_xml_empty_tag_unencoded
_xml_data_element
_xml_string_element
_xml_si_element
_xml_rich_si_element
_xml_number_element
_xml_formula_element
_xml_inline_string
_xml_rich_inline_string
_escape_attributes
_escape_data
__dict__
__weakref__
__repr__
__hash__
__str__
__getattribute__
__setattr__
__delattr__
__lt__
__le__
__eq__
__ne__
__gt__
__ge__
__new__
__reduce_ex__
__reduce__
__subclasshook__
__init_subclass__
__format__
__sizeof__
__dir__
__class__

浏览此列表后,我发现了这组属性:

dim_rowmin
dim_rowmax
dim_colmin
dim_colmax

它们返回工作表内数据的第一行和最后一行/列。 我用它们来制作我自己的大小函数来解决我自己的问题。

def xlxs_size(worksheet):
return(worksheet.dim_colmax, worksheet.dim_rowmax)

我读到你的问题,因为我遇到了同样的问题,所以希望这对你也有帮助。

最新更新