def get_chart(workbookPath, imageName="XLChart"): import os, time wbPath, wbFile = os.path.split(workbookPath) import pythoncom pythoncom.CoInitialize() from pyxlchart import Pyxlchart ChartObj = Pyxlchart() ChartObj.WorkbookDirectory = wbPath ChartObj.WorkbookFilename = wbFile ChartObj.ImageFilename = imageName timeDir = str(time.time()) os.makedirs(os.path.join(request.folder, 'static\\images\\temp', timeDir)) exportFolder = os.path.join(request.folder, 'static\\images\\temp', timeDir) ChartObj.ExportPath = exportFolder ChartObj.ReplaceWhiteSpaceChar = '_' ChartDetailList = ChartObj.start_export() ChartDetails = dict(chartdetail = ChartDetailList, webfolder = os.path.join('static/images/temp/',timeDir),osfolder = exportFolder) return ChartDetails
from pyxlchart import Pyxlchart xl = Pyxlchart() xl.WorkbookDirectory = "D:\\" xl.WorkbookFilename = "chart_column.xlsx" xl.SheetName = "" #xl.ImageFilename = "MyChart1" xl.ExportPath = "d:\\" xl.ChartName = "" xl.start_export()