Home > other >  Openpyxl operation excel file standard code (think), Posting to spare.
Openpyxl operation excel file standard code (think), Posting to spare.

Time:11-23

You may use, through the use of the feeling after openpyxl than XLRD, XLWT much better.

 
The import numpy as np
The from pathlib import Path
The import openpyxl

Fp=Path. CWD ()/" xlsDemo
"Xlfilename="test. XLSX"
Tbname="test"

If not you need. The exists () :
Fp. Mkdir (parents=True)

Fp=fp/xlfilename

If you need. The exists () :
Wb=openpyxl. Open (fp)
If tbname not in wb. Sheetnames:
WSH=wb. Create_sheet (title=tbname)
The else:
The WSH=wb (tbname)
The else:
Wb=openpyxl. Workbook ()
WSH=wb. Create_sheet (title=tbname)

Bb=np. Array (,3,5,6,8,7,9,10 [2])
K=0
For I in range (1, 5) :
For j in range (1, 3) :
The WSH. Cell (I, j) value=https://bbs.csdn.net/topics/bb [k]. K +=1

Wb. Save (fp)
Wb. Close ()

CodePudding user response:

A blemish, cannot use an array of regional one-time assignment, may also is not found, who can provide your method?
  • Related