Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sat Jan 28, 2017 1:31 am

Hi,
I have a problem when save a bar chart from xlsx to image.
The labels from series are saved in the image with different aligment (vertical) then created in the excel file (horizontal), see the images attached.
I'm using SPIRE.XLS version 7.11.49 and the following code:

Spire.Xls.Workbook workbook = new Spire.Xls.Workbook();
workbook.LoadFromFile(excelFile, ExcelVersion.Version2010);
//First change some values
Spire.Xls.Worksheet wSheet = (Spire.Xls.Worksheet)workbook.Worksheets.Where(s => s.Name == "Demografias").First();
wSheet.Range["A4"].NumberValue = new Random().Next(50, 500);
workbook.Save();
//Export charts as images
System.Drawing.Image[] imgs = workbook.SaveChartAsImage(wSheet);
for (int i = 0; i < imgs.Length; i++) {
imgs[i].Save(string.Format("img-{0}.png", i), ImageFormat.Png);
}

Thanks in advance!
Federico
Attachments
Exported-barchart.png
Exported image from xlxs
Exported-barchart.png (15.54 KiB) Viewed 3896 times
Original-barchart.png
Original chart created in excel
Original-barchart.png (20.95 KiB) Viewed 3896 times

fedeamen
 
Posts: 3
Joined: Thu Jan 19, 2017 11:24 pm

Mon Jan 30, 2017 3:24 am

Dear fedeamen,

Sorry for late reply as weekend.
I have tested the scenario, but didn't find that issue.
Please offer us sample file which has that issue for further investigation.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jan 30, 2017 11:11 am

Hi! thanks for response.
Attached is the excel file I'm using and the result exported image. The bar chart axis is set right to left display and saved in Excel 2007.

This is the code:
Code: Select all
 string excelFile = @"Report.xlsx";
 System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

  Spire.Xls.Workbook workbook = new Spire.Xls.Workbook();
  workbook.LoadFromFile(excelFile, ExcelVersion.Version2007);
  Spire.Xls.Worksheet wSheet = (Spire.Xls.Worksheet)workbook.Worksheets.Where(s => s.Name == "Demografias").First();
  wSheet.Range["A4"].NumberValue = new Random().Next(50, 500);
  wSheet.Range["B4"].NumberValue = new Random().Next(50, 500);
  wSheet.Range["C4"].NumberValue = new Random().Next(50, 500);
  wSheet.Range["D4"].NumberValue = new Random().Next(10, 300);
  wSheet.Range["E4"].NumberValue = new Random().Next(50, 500);
  workbook.Save();
  ystem.Drawing.Image[] imgs = workbook.SaveChartAsImage(wSheet);
  for (int i = 0; i < imgs.Length; i++) {
       imgs[i].Save(string.Format("img-{0}.png", i), ImageFormat.Png);
  }
Attachments
Report.zip
(24.54 KiB) Downloaded 655 times

fedeamen
 
Posts: 3
Joined: Thu Jan 19, 2017 11:24 pm

Tue Jan 31, 2017 9:28 am

Dear fedeamen,

Thank you for providing the documents.
I have noticed the issue and referred it to our dev team for investigating. If we work out the solution towards the issue,we will let you know at once.
Sorry for the inconvenience.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Tue Jan 31, 2017 10:55 am

Thanks Nina!
I'm aware of your answer then.

fedeamen
 
Posts: 3
Joined: Thu Jan 19, 2017 11:24 pm

Wed Jul 05, 2023 1:48 am

Hi fedeamen,

Thank you for your patience.

I'm glad to inform you that the issue has been resolved. Welcome to download and test Spire.XLS Pack(Hotfix) Version:13.7.0.
Our website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
NuGet link: https://www.nuget.org/packages/Spire.XLS/

If you have any questions, please let us know.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS