示例#1
0
        private static IEnumerable <PreviewChart> PreCharts(DocumentInfo doc, string zipOutPath, string folderName)
        {
            var charts = new List <PreviewChart>();

            foreach (var sheet in doc.Workbook.Worksheets)
            {
                foreach (var chart in sheet.Charts)
                {
                    var imgFileName = $"{sheet.Name} {chart.Name}.png";
                    var imgPath     = $"{zipOutPath}/{imgFileName}";
                    chart.ToImage(imgPath);

                    var previewChart = new PreviewChart
                    {
                        WorkbookHash  = doc.GetHashCode(),
                        SheetIndex    = sheet.Index,
                        ChartHash     = chart.GetHashCode(),
                        ChartName     = Path.GetFileNameWithoutExtension(imgPath),
                        ImgFolderName = folderName,
                        ImgFileName   = imgFileName
                    };
                    charts.Add(previewChart);
                }
            }

            return(charts);
        }