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.6 is quite different from the previous version, so please note before you update it.

Install

pip install wordexceltools

Main Functions

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

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.6.tar.gz (17.4 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.6-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wordexceltools-1.0.6.tar.gz
  • Upload date:
  • Size: 17.4 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.6.tar.gz
Algorithm Hash digest
SHA256 7ca7e19f9102e5799805dda6754c7425039d57af6883fff19cf911aefba8adf9
MD5 704f4dfe7504e411ebb03964f61f65d5
BLAKE2b-256 f97d8098103e02bf1476cb30911758446c1a8c6bf8ce3988bbc6b1660381235e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wordexceltools-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 139f69770708e03175763c12a435c8283b8b15fd592c0e7d0b1488e8102f680c
MD5 c5ff3d26624a08582c252c783dd9b7e0
BLAKE2b-256 4d9e5d35682cb39476d800734a9cf5c79606230a8a240dd024cdbd9e09c8f6ae

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