We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart colors not rendered correctly when saving as pdf with wb.save()

Hi ,
I was using the workbook.Save(Stream,pdf) function call to save an excel document as a pdf.

I noticed a couple of things which are not being rendered properly in the pdf.

1) The chart colors assigned by manually created theme colors using workbook.createThemeColor() do not appear in the saved pdf . They are overwritten by unknown theme with a disclaimer message from aspose. However this happens neither in the print preview nor when I save the file as an excel file and then convert it into a pdf using excel save as option.

2) The characters like \t are used for formatting are being rendered as square boxes in the pdf

Please look into the issue and kindly help me with this. Let me know if this a known issue and if there is a solution for it.
I have attached the images which show the same.

Mahesh

Hi,

Thanks for your posting and using Aspose.Cells.

Please provide us your source input file. We will look into your issue and if we find any issue, we will log it in our database so that it could be fixed.

Hello Shakeel,
Thank you for your quick response .

We have identified additional information regarding our problem with chart colors.
We are currently saving the dynamically generated excel file to a memory stream by using wb.Save(Stream,SaveFormat.pdf) ;

However when we saved the workbook to the local disk first , loaded the same and saved it again into the memory stream as a pdf, the color scheme is correctly applied.

I also was wondering if you were asking for the source excel sheet generated or our source code .Could you please clarify this for me.

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please provide us your source excel sheet and simple runnable source code replicating this issue with the latest version: Aspose.Cells
for .NET v7.4.3.2
. We will look into your issue and if we find any problem, we will log it in our database.

Hi shakeel,
I have included a simple web application which reproduces the problem I’m having. Please run it and verify the same.

The color code in excel and pdf files are rendered different . Index.aspx is the home page.
It also demonstrates the tab problem.

Please let me know if this works.

Thanks,
Mahesh

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please provide us your excel template file which you are converting to pdf to look into this issue. I did not find any excel file in your archive.

Hi Shakeel,
I am not supposed to save the excel file anywhere. That is not the issue . My problem is with in-memory generation of excel and pdf.

Please run the application provided and click on the buttons in the index.aspx page to download the generated excel and pdf files. The problem will become evident.

Thanks,
Mahesh

Hi,

You provided an entire website which is not needed. Only the simple runnable code or project was needed to look into this issue. Please provide us your simple runnable code. We will look into your issue and if we found any error, we will log it in our database for a fix.

Hi Shakeel ,
The website has been created as sample running code just to demonstrate the problem. It has only one web page which just 2 buttons (one for pdf,one for excel).

There is one code file AsposeForum.cs which has the logic behind and the aspx.cs for the single web page.

Kindly run the application and verify . Please let me know if you have any difficulties getting the project to work.
Mahesh

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to observe this issue. The colors are not rendering correctly in the output pdf. We have attached the screenshot for a reference. Also attached the output xlsx and pdf files.

We have logged this issue in our database. We will look into it and resolve this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41697.

C#


Workbook wb = new Workbook();


Worksheet sheet = wb.Worksheets[0];

wb.SetThemeColor(ThemeColorType.Background1, Color.White);

wb.SetThemeColor(ThemeColorType.Text1, Color.Black);

wb.SetThemeColor(ThemeColorType.Background2, Color.White);

wb.SetThemeColor(ThemeColorType.Text2, Color.Red);

wb.SetThemeColor(ThemeColorType.Accent1, Color.FromArgb(56, 63, 68)); //blue-gray

wb.SetThemeColor(ThemeColorType.Accent2, Color.FromArgb(136, 140, 143));//Gray-50%

wb.SetThemeColor(ThemeColorType.Accent3, Color.FromArgb(195, 197, 199));//Gray-25%

wb.SetThemeColor(ThemeColorType.Accent4, Color.FromArgb(182, 223, 26));//LIME

wb.SetThemeColor(ThemeColorType.Accent5, Color.FromArgb(195, 218, 94));//Lime

wb.SetThemeColor(ThemeColorType.Accent6, Color.FromArgb(211, 236, 118));//lime


Cell headerCell = sheet.Cells[“A1”];

int currRow = headerCell.Row;

int currCol = headerCell.Column;


for (int i = 0; i < 3; i++)

{

for (int j = 0; j < 5; j++)

{

sheet.Cells[currRow + j, currCol + i].PutValue(200);

sheet.Cells[currRow + j, currCol + 4].PutValue("\t");

}


}




//NOW PRINT GRAPH

int chartIndx = sheet.Charts.Add(ChartType.ColumnStacked, currRow + 10, currCol, currRow + 40, 20);


Chart chart = sheet.Charts[chartIndx];


//Set Properties of categoryaxis title

chart.CategoryAxis.Title.Text = “Project”;

chart.CategoryAxis.Title.Font.Color = Color.Black;

chart.CategoryAxis.Title.Font.IsBold = true;

chart.CategoryAxis.Title.Font.Size = 10;


chart.ChartArea.Area.ForegroundColor = Color.White;

chart.PlotArea.Area.ForegroundColor = Color.White;


for (int k = 1; k <= 3; k++)

{

chart.NSeries.Add(“A” + 1 + “:A” + 5, true);

}


foreach (Worksheet ws in wb.Worksheets)

{

ws.PageSetup.FitToPagesWide = 1;

}


bool pdf = true;

string filePath = @“F:\Shak-Data-RW\Downloads”;



if (pdf)

wb.Save(filePath + “output.pdf”, SaveFormat.Pdf);

else

wb.Save(filePath + “output.xlsx”, SaveFormat.Xlsx);



Hi,


We have analyzed your issue a bit. Well, if you need to generate/render XLSX file format or render the 2007/2010 charts in the PDF file, you would require to sepecify the FileFormatType to Xlsx when creating workbook object. For your information, if you don’t specify the file formatting type, the default format would be always XLS (Excel 97-2003).

Please change your line of code i.e.

Workbook wb = new Workbook();
to:
Workbook wb = new Workbook(FileFormatType.Xlsx);
it will give you the PDF file with correct colors in the saved PDF file.

thank you.