Good Morning.
I want to convert an Excel with some cells with conditional formatting to show different colors to PDF, but the PDF always shows the same color in all cells.
File xlsx:
File PDF:
Sometimes the first time I run the conversion it does it right, but the others fail.
I use net core 3.1 and xlsio.net.core version 191.0.54.
Thanks.
Thanks for your quick response.
I have installed the latest version (19.3.0.47) but the colors appear worse than before as only the color is displayed in one cell.
I am attaching the Excel file (template.xlsx).
My code:
var ruta = Path.Combine(_env.ContentRootPath, @"Plantillas\");
MemoryStream outputStream = new MemoryStream();
using (ExcelEngine excelEngine = new ExcelEngine())
{
try
{
XlsIORenderer renderer = new XlsIORenderer();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2010;
FileStream inputStream = new FileStream(plantillaExcel, FileMode.Open);
IWorkbook Ilibro = application.Workbooks.Open(inputStream);
IWorksheet worksheet = Ilibro.Worksheets[0];
//Initialize the PdfDocument Class
PdfDocument pdfDoc = new PdfDocument();
//Initialize the ExcelToPdfConverterSettings class
XlsIORendererSettings settings = new XlsIORendererSettings();
settings.IsConvertBlankPage = false;
settings.ExportQualityImage = true;
settings.RenderBySheet = true;
settings.LayoutOptions = LayoutOptions.NoScaling;
settings.AutoDetectComplexScript = true;
//Assign the output PdfDocument to the TemplateDocument property of ExcelToPdfConverterSettings
settings.TemplateDocument = pdfDoc;
settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;
//Convert the Excel document to PDf
pdfDoc = renderer.ConvertToPDF(Ilibro, settings);
inputStream.Dispose();
pdfDoc.Save(outputStream);
pdfDoc.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
return outputStream;
Thanks.
Thanks.
I will wait to be notified when it is available.
Regards.
Thanks for the quick reply.
I have updated the package but the problem is not resolved.
The first time the PDF file is generated, it works fine:
But the second time the colors are all the same:
Is it necessary to do some kind of initialization before generating the PDF?
I am looking forward to your response.
Regards.
Hello, good Morning.
Have you managed to correct the problem?
Regards.
Hello.
When I run the application in debug, the dll file changes to the old version.
How can I test the new dll?
NOTE:
I have tried to change the dll file in production and it gives an error.
Sorry but I don't understand.
I don't have the Assembly Manager installed. In my project I have these references:
How can I test the dll file that was sent to me?
Can't you create another version to install (for example 19.3.0.49)?
Regards
I have added the reference to the dll file that was sent to me:
but I get this error:
Regards.
Hello.
Can this topic tell me something? Can you update the xlsio version?
Regards.
Thanks.
It works better (it always outputs the same), but I see that there are some values that appear black:
Can you check it out?
R
Thanks for the example.
I have already seen the problem where the data appears black.
If the value has many decimal places it does not look good, for example 0.9999333377774815
If I reduce the number of decimal places, it works fine!
Thanks for everything !!!
Thanks.
Here I am sending you an example where you can see that with a number with many decimal places, the pdf is not generated well.
If I put less decimal places it works fine.
Regads.
Perfect!
Now it works correctly.
Thank you so much for everything !