일부 작업을 자동화하고 궁극적으로 기존 스프레드 시트에 쓰기 위해 Python을 사용하고 있습니다. xlwt, xlrd 및 xlutils 모듈을 사용하고 있습니다.파이썬은 기존 Excel 시트에 (xlwt)을 작성하고 차트 및 서식을 삭제합니다.
그래서 내가 설정하는 방법은 파일을 열고 복사본을 작성한 다음 동일한 파일에 다시 저장하는 것입니다. 마지막 단계를 수행 할 때 주석 및 차트와 같은 모든 형식이 제외됩니다. 그 주위에 방법이 있습니까? 나는 그것이 탁월한 목표와 관련이 있다고 생각합니다.
는 당신에게 감사import xlwt
import os
import xlrd, xlutils
from xlrd import open_workbook
from xlutils.copy import copy
style1 = xlwt.easyxf('font: name Calibri, color-index black, bold off; alignment : horizontal center', num_format_str ='###0')
script_dir = os.path.dirname('_file_')
Scn1 = os.path.join(script_dir, "\sample\Outlet.OUT")
WSM_1V = []
infile = open (Scn1, "r")
for line in infile.readlines():
WSM_1V.append(line [-10:-1])
infile.close()
Existing_xls = xlrd.open_workbook(r'\test\test2.xls', formatting_info=True, on_demand=True)
wb = xlutils.copy.copy(Existing_xls)
ws = wb.get_sheet(10)
for i,e in enumerate(WSM_1V,1):
ws.write (i,0, float(e),style1)
wb.save('test2.xls')
코드를 표시하는 것이 가장 좋습니다. 그렇지 않으면 대답하기가 어렵습니다. –
http://stackoverflow.com/questions/3723793/preserving-styles-using-pythons-xlrd-xlwt-and-xlutils-copy –
@TimWilliams :이 경우 대답하기가 어렵지 않습니다. 코드는 거의 완전히 관련성이 없습니다. 관련 패키지가 무엇인지 아는 경우 OP가 요청하는 패키지는 해당 패키지에서 지원되지 않습니다. –