Home > other >  Python Excel and word
Python Excel and word

Time:09-20

Excel data integer, decimal, Python read Excel data imported into the word table, why display are decimal?


The import docx
The import XLRD
The from docx. Enum. The text import WD_ALIGN_PARAGRAPH

Sx=XLRD. Open_workbook (' 12. XLSX) # read
People=sx. Sheet_by_index (0)
# get the document
The file=docx. Document (' 1211. Docx)
Tables=file. # tables for files in the table set
Table=tables [1] the first form of # file
For I in range (3, 14) : # form data read from the form line 1 began circulating
A=people. Row_values (I)
For j in range (0, 2) :
Table. The cell (I, j) text=STR (a [j])
Table. The cell (I, j) paragraphs [0]. Centered alignment=WD_ALIGN_PARAGRAPH. CENTER #
The file. Save (r 'C: \ Users \ Administrator \ Desktop \ twoPage docx')

CodePudding user response:

Haven't used XLRD, estimates that if you read a list of a column, whether can avoid that, in addition, the suggestion is that pandas processing data, so that faster, XLRD makes me around a lot of circles, finally use openpyxl + pandas are relatively good, to not support XLS format, refer to https://blog.csdn.net/weixin_45903952/article/details/104786048
Change my

CodePudding user response:

Oh, is converted to word, I think is wrong
  • Related