Hi Audrey,
Thanks for your posting and using Aspose.Cells.
We were able to observe the issue mentioned by you in your post with your source Excel file, output PDFs generated with Excel and Aspose.Cells and screenshot that highlights the issue. We observed the same by generating the PDF with Aspose.Cells at our end.
We have logged this issue in our database for investigation. We will look into it and see if we could work like MS-Excel and fix 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-43117 - Times - Times New Roman - Different FONT processing
I have also attached the output pdf generated with the following code for a reference
C#
string filePath = @“F:\Shak-Data-RW\Downloads\TIMES+test.xlsx”;
Workbook workbook = new Workbook(filePath);
workbook.Save(filePath + “.out.pdf”);
Hi Audrey,
Thanks for using Aspose.Cells.
We have evaluated this issue further. As the user said, “Times” is not in the list of fonts, so we will find a
font that we have got to show the cell string. This process is
different with what Excel does. And we do not know how Excel does it now.
For now, you can try change cell font name “Times” to “Times New Roman” by code.
Thanks for your response.
Did you mean:
foreach (Aspose.Cells.Worksheet sheet in workbook.Worksheets)
{
foreach(Aspose.Cells.Cell cell in sheet.Cells)
{
Aspose.Cells.Style style = cell.GetStyle();
if (style.Font.Name == "Times")
{
style.Font.Name = "Times New Roman";
cell.SetStyle(style);
}
}
}
Or is there a better way to change all "Times" fonts to "Tiems New Roman" ?
Hi Audrey,
Thanks for posting and using Aspose.Cells.
Yes, you got it right. There is no other better way, you are already using the efficient way of replacing the font name. I have also tested your code and found the pdf generated by it is same as expected.
I have attached the output PDF generated by the code for your reference.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\TIMES+test.xlsx”;
Workbook workbook = new Workbook(filePath);
foreach (Aspose.Cells.Worksheet sheet in workbook.Worksheets)
{
foreach(Aspose.Cells.Cell cell in sheet.Cells)
{
Aspose.Cells.Style style = cell.GetStyle();
if (style.Font.Name == “Times”)
{
style.Font.Name = “Times New Roman”;
cell.SetStyle(style);
}
}
}//foreach
workbook.Save(filePath + “.out.pdf”);