Skip to main content

A tool for quickly operating on Excel files and generating Word documents based on docx, python-docx and openpyxl.

Project description

WordExcelTools

A tool for quickly operating on Excel files and generating Word documents based on docx, python-docx and openpyxl.

The current version 1.0.7 is quite different from the previous version, so please note before you update it.

Install

pip install wordexceltools

Main Functions

1: excel_add_sheet(source_excel, new_sheet_name)
2: excel_copy_file(source_excel, target_excel)
3: excel_delete_file(target_excel)
4: excel_delete_sheet_by_index(source_excel, sheet_index)
5: excel_delete_sheet_columns(source_excel, sheet_index, target_column_index, number_of_columns)
6: excel_delete_sheet_rows(source_excel, sheet_index, target_row_index, number_of_rows)
7: excel_get_column_keyword_count(sheet, column_name, keyword)
8: excel_get_column_len(sheet, column_name)
9: excel_get_column_list(sheet, column_name)
10: excel_get_column_str_custom(sheet, column_name, separator, end_mark)
11: excel_get_columns_keyword_counts(sheet, platform_prefix, result_suffix)
12: excel_get_sheet(source_excel, sheet_index)
13: excel_get_sheet_cell_date_value(sheet, row, column)
14: excel_get_sheet_cell_value(sheet, row, column)
15: excel_get_sheet_col_values(sheet, col_index)
16: excel_get_sheet_name(sheet_data, sheet_index)
17: excel_get_sheet_row_col(sheet)
18: excel_get_sheet_row_values(sheet, row_index)
19: excel_get_sheets_name_row(source_excel)
20: excel_insert_sheet_columns(source_excel, sheet_index, target_column_index, number_of_columns)
21: excel_insert_sheet_rows(source_excel, sheet_index, target_row_index, number_of_rows)
22: excel_set_sheet_cell_value(source_excel, sheet_index, row, column, value)
23: word_add_custom_heading(document, level, text)
24: word_add_custom_paragraph(document, text, style)
25: word_add_custom_table(document, row_count, column_count, style, font_size, spacing_before)
26: word_add_figure_caption(document, caption_text)
27: word_add_indented_paragraph(document, text)
28: word_add_ordered_list(document, items, index_style, indentation)
29: word_add_table_caption(document, caption_text)
30: word_docxinitial(doc, text_font_type, text_font_size, text_font_line_spacing, text_header, text_footer)
31: word_get_platform_results(list_test_objs, platform_prefix, result_suffix)
32: word_get_section_number(paragraph_text)
33: word_get_table_cell_text(table, row_index, column_index)
34: word_merge_cells(table, start_row, start_column, end_row, end_column)
35: word_merge_cells_by_column(table, column_index)
36: word_set_number_to_roman(number)
37: word_set_table_alignment(table, start_row, start_column, end_row, end_column, horizontal_alignment, vertical_alignment)
38: word_set_table_cell_text(table, row_index, column_index, text)
39: word_set_table_style(table, font_size, spacing_before)
40: word_setsectionformat(doc)

Example

from docx import Document
import openpyxl
import wordexceltools

soucrce_excel = "./test.xlsx"
sheet0 = excel_get_sheet(source_excel, 0)
print(sheet0.max_column)
print(sheet0.max_row)
print(excel_get_sheet_cell_value(sheet0, 2, 2))
print('========================')
print(excel_get_sheet_row_col(sheet0))
print('========================')

print(excel_get_sheet_row_values(sheet0, 1))
print(excel_get_sheet_col_values(sheet0, 1))
print('========================')

excel_insert_sheet_columns(source_excel, 0, 1, 2)

excel_insert_sheet_rows(source_excel, 0, 2, 3)

for i in range(3,6):
    for j in range(2,4):
        excel_set_sheet_cell_value(source_excel,0,i,j,f"{i}x{j}")
#
excel_delete_sheet_columns(source_excel, 0,2,1)
excel_delete_sheet_rows(source_excel, 0,2,2)
excel_add_sheet(source_excel,"test1")
excel_add_sheet(source_excel,"test2")
print(excel_get_sheets_name_row(source_excel))
excel_delete_sheet_by_index(source_excel,3)
excel_delete_sheet_by_index(source_excel,2)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wordexceltools-1.0.7.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wordexceltools-1.0.7-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file wordexceltools-1.0.7.tar.gz.

File metadata

  • Download URL: wordexceltools-1.0.7.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for wordexceltools-1.0.7.tar.gz
Algorithm Hash digest
SHA256 8723a9c6f14ce32931863cbf7960a2ab5e1b5e086fac6b61cc77f93e23334f3e
MD5 43c7981addae41e795ec3d44034a4696
BLAKE2b-256 8be25ff135620db96aa12836b189bcc19466150bbdb6be9c49e54f368b94aaa1

See more details on using hashes here.

File details

Details for the file wordexceltools-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: wordexceltools-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for wordexceltools-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f025cd81971fd58b88a5918c385f9973aeb6cea978bb79acfc7e101b4c24bb77
MD5 9236a5e12f19e5a086d2bf6295d63e1d
BLAKE2b-256 d8a37e704d17247ee31aad5917e8f0640e45afc1f6fdcfcc9bed1d0ae3da56ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page