Spire.XLS is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Wed Jul 14, 2021 5:42 am

After I prepared the raw data, I want to refresh the related chart and save it as image.
Following is my functional code:

Workbook wb = new Workbook();
wb.LoadFromFile(finalFileName, ExcelVersion.Version2016);

//Following code doesn't work, if I only call the SaveToFile function, the chart won't be refreshed.
//Worksheet ws = wb.Worksheets[0];
//ws.Copy(ws.Range["A2:B2"], ws.Range["A3:B3"], true);
//XlsPivotTable pt = wb.Worksheets[0].PivotTables[0] as XlsPivotTable;
//pt.Cache.IsRefreshOnLoad = true;
//wb.SaveToFile("working//final.xlsx", ExcelVersion.Version2016);

//After I called the SaveAsImage, and call RefreshChart again, the Chart will be refreshed correctly.
wb.SaveAsImage(0, 100, 100);
foreach (Worksheet ws2 in wb.Worksheets)
{
for (int iIndex = 0; iIndex < ws2.Charts.Count; iIndex++)
{
Chart ct = ws2.Charts[iIndex];
ct.RefreshChart();
Image img = wb.SaveChartAsImage(ws2, iIndex);
img.Save($"working//{ws2.Name}-{ct.Name}.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
wb.Dispose();

Following the code above, I can export the image for each chart. But part of the format of the chart image is mess.
I have uploaded the template and image files. and I use the FreeSpire.XLS 10.10.0 version.
Could you help me to solve the problem, thanks!
Attachments
demo-2021-07-14-13-36-39.zip
template file and image file
(186.04 KiB) Downloaded 205 times

flyenter
 
Posts: 4
Joined: Tue Jul 13, 2021 1:44 pm

Wed Jul 14, 2021 9:21 am

Hello,

Thanks for your inquiry.

I tested your case with both FreeSpire.XLS 10.10.0 and the latest commercial version (Spire.XLS Pack(Hotfix) Version:11.7.0), I indeed noticed that the generated image was not correct. I have logged this issue in our bug tracking system with the ticket SPIREXLS-3344.

If there is any update, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1568
Joined: Tue Jul 09, 2019 2:22 am

Wed Jul 14, 2021 10:15 am

Thanks for your quick response.

I have tried to add 2 chart sheets which based on the different row data sheet within same excel file.
and try to export the chart as image. but I just got one correct image, and another one is incorrect. (looks like the data doesn't be refreshed.)

After I removed the correct chart sheet, and run the project again. the previous incorrect chart can be saved as image correctly.

While I recover to the previous 2 chart sheets case, the issue reappeared.

Could you help us on the issue?

Thanks!

flyenter
 
Posts: 4
Joined: Tue Jul 13, 2021 1:44 pm

Thu Jul 15, 2021 3:03 am

Hello,

Thanks for your reply.

I did an initial test but did not encounter the issue you mentioned. To help us investigate further, please provide your input file and your full test code. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1568
Joined: Tue Jul 09, 2019 2:22 am

Fri Jul 16, 2021 2:14 am

I have uploaded the example case. please pay attention on the CopyImage.png and PaySummary-chtSummary.png, the charts couldn't reflected the data volume.
Attachments
SpireXlsDemo.zip
example case
(25.7 KiB) Downloaded 192 times

flyenter
 
Posts: 4
Joined: Tue Jul 13, 2021 1:44 pm

Fri Jul 16, 2021 10:15 am

Hello,

Thanks for your sharing.

I have reproduced your issue and logged it in our bug tracking system with the ticket SPIREXLS-3359. If there is any update, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1568
Joined: Tue Jul 09, 2019 2:22 am

Thu Jul 29, 2021 3:20 am

Hi,

Do you have the estimated time for the issue fix?

flyenter
 
Posts: 4
Joined: Tue Jul 13, 2021 1:44 pm

Thu Jul 29, 2021 6:10 am

Hello,

Thanks for your inquiry.

I checked the status of your issues but found that they have not been resolved. Sorry we are unable to give you an estimated time at present. Please spare us more time.
We will keep you informed if there is any update. Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1568
Joined: Tue Jul 09, 2019 2:22 am

Tue Sep 14, 2021 10:15 am

Hello,

Thanks for your patience.

Glad to inform you that we just released Spire.XLS Pack(Hotfix) Version:11.9.2, which fixes the issues SPIREXLS-3344 and SPIREXLS-3359. Kindly note that for both issues, you need to call the method "wb.CalculateAllValue();" to recalculate the formula values before converting.

Website download link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet download link: https://www.nuget.org/packages/Spire.XLS/11.9.2

Code:

Code: Select all
            //#SPIREXLS-3344
            //...
            wb.CalculateAllValue();
            pt.CalculateData();
            //...

            //#SPIREXLS-3359
            //...
            wb.CalculateAllValue();
            foreach (Worksheet wkSheet in wb.Worksheets)
            {
                for (int iIndex = 0; iIndex < wkSheet.Charts.Count; iIndex++)
                {
                    Chart ct = wkSheet.Charts[iIndex]; ct.PivotTable.CalculateData();//计算关联透视表
                    ct.RefreshChart();
                    Image img = wb.SaveChartAsImage(wkSheet, iIndex);
                    img.Save($"working//{wkSheet.Name}-{ ct.Name}.png", System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            //...



Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1568
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS