Home > other >  How to use win32com write large amounts of data to excel table
How to use win32com write large amounts of data to excel table

Time:11-18

Due to special reasons of the project, need to use Excel win32com do automated processing, the main process is:
1. Incorporating two CSV data to the target a sheet in Excel;
2. Refresh target Excel all pages (due to some pages will do some calculation and statistics, according to the sheet 1), new results,
But from 1 data is very big, there are about 1 million rows of data, if you use the sheet set of Cells to value, speed too slow, I don't know what other good way,

Code is roughly as follows:
 
Table_1=read_from_csv1 ()
Table_2=read_from_csv2 ()

Application=win32com. Client. Dispatch (" Excel. Application ")
Application. The Visible=True
Workbook=Application. Workbooks. Open (' c: \ \ target. XLSX)
SHT=Workbook. Worksheets (' Test ')
SHT. UsedRange. ClearContents ()
For row_number, row in enumerate (table_1) : # for each row in the report
For col_number, val in enumerate (row) :
SHT. Cells (col_number row_number + 1, + 1). The Value=https://bbs.csdn.net/topics/val
Current_row_number=row_number

CodePudding user response:

It's not reasonable to use win32

with pandas, speaking, reading and writing

CodePudding user response:

Mainly there are many VBA, if you need to write workload is too heavy, thank you!
  • Related