代码
2020-04-14 本文已影响0人
猪猪一号
from openpyxl import Workbook
from openpyxl import load_workbook
from itertools import islice
wb = load_workbook('123.xlsx')
sheet_ranges = wb['Sheet1']
hCells = sheet_ranges['H']
xCoord = ['X']
yCoord = ['Y']
for cell in islice(hCells, 1, None):
print(cell.value)
coord = cell.value.split(",")
xCoord.append(coord[0])
yCoord.append(coord[1])
ab = Workbook()
ab.save('result.xlsx')
result = load_workbook('result.xlsx')
result_workSheet = ab.active
for x in range(1,(len(yCoord)+1)):
for y in range(1,3):
result_workSheet.cell(row=x, column=y)
print(len(yCoord))
print(result_workSheet['A'])
print(result_workSheet['B'])
i = 0
for x_Cells in result_workSheet['A']:
x_Cells.value = xCoord[i]
i = i + 1
j = 0
for y_Cells in result_workSheet['B']:
y_Cells.value = yCoord[j]
j = j + 1
ab.save('result.xlsx')