Does Aspose.Cells support previewing before printing?

Test with the latest 20.7 release

The problem remains

@Diego2020,
We are analyzing this issue and need further assistance as follows:

Please make sure that:

  1. The DPI setting of your manchine is 100%
  2. The used font “等线” is installed

Then, run the following code:

Console.WriteLine("DPI :" + CellsHelper.DPI);
Workbook wb = new Workbook("Test.xlsx");
Console.WriteLine("Default font: " + wb.DefaultStyle.Font);

Cells cells = wb.Worksheets[0].Cells;

Console.WriteLine("Column A width : {0}, width  in Pixel: {1}, width in Inch: {2}.",
	cells.GetColumnWidth(0), cells.GetColumnWidthPixel(0), cells.GetColumnWidthInch(0));
Console.WriteLine("Column I width : {0}, width  in Pixel: {1}, width in Inch: {2}.",
	cells.GetColumnWidth(8), cells.GetColumnWidthPixel(8), cells.GetColumnWidthInch(8));

wb.Save("output.pdf");

Share us the Console output text of above code and the saved pdf file “output.pdf”

I use the Windows 10 system.

Don’t know how to set DPI

“等线” fonts have been installed

The test code and output are attachedTest.zip (5.8 MB)

@Diego2020,
Thank you for sharing more information. We are analyzing it and will share our feedback soon.

@Diego2020,
We have analyzed your feedback and observed that “等线” is not used in the PDF. This issue seems to be related to fonts, therefore you may try the scenario again by adding following code in the beginning of your main().

 //set DengXian Regular font path on your machine 
string DengXianFontPath = //e.g. @"C:\Windows\Fonts\Deng.ttf" on my side
byte[] fontData = File.ReadAllBytes(DengXianFontPath);
Console.WriteLine("Font Data length: " + fontData.Length);
if(fontData.Length > 0)
{
    FontConfigs.SetFontSources(new FontSourceBase[] { new FileFontSource(DengXianFontPath) });
}

//Rest of the code is here

Please note that although, it seems that the font “等线” is installed in your environment according to the screenshot. But it seems that the font can’t be accessed from the program. So we suggested the above code at the beginning of your code.

Also we noted that your DPI is 96 which is OK. However you may test the scenario by setting DPI in Windows 10 as shown the attached image. This setting is there in Windows->Settings.
Win10_DPI_Setting.jpg (178.0 KB)

My Scale and layout was set to 100% before.

Add your suggested code.

The problem remains.

I don’t think it was the font that caused the problem.

Please help me with this problem.

Or print preview in the Aspose
.cells class library.

All the code and screenshots are attached.Test.zip (6.4 MB)
Attached is a screenshot of the Excel print preview

@Diego2020,
We have tested it again and shared the output on our side, everything is OK. And DengXian font is used in the output pdf file. Output_Aspose_side.zip (171.2 KB)

Could you please try your program on another machine with DPI setting (Display scaling) is 100% and font “等线” is installed.

Also, please try the following code on your side: We have only changed the default font name “等线” to “DengXian”(English name of the font)
ChangeDefaultFont.zip (1.2 KB)

Let us know your feedback.

I tested the program on another computer.

The result of the execution is the same as before.

What version of Aspose.Cells.dll did you use?

@Diego2020,
We have used the latest version of Aspose.Cells 20.7. We are analyzing this feedback and will share our comments soon.

Thank you for following up on this issue.

Waiting for your solution.

This problem has been bothering me for a long time

@Diego2020,
We have further evaluated this scenario and would like you tp try the following:

  1. With your sample code shared here, try the code on your side such that the default font name “等线” is changed to “DengXian”(English name of the font)". This test should be run with the regular release Aspose.Cells for .NET v20.7.
  2. You may also try the scenario keeping the font name as “等线” but using the attached latest hotfix v20.7.7 below and share the feedback.
    Aspose.Cells20.7.7 For .Net4.0.Zip (5.4 MB)

Tested with version 20.7.7.0(must be 20.7.7.0,20.7.0.0 is incorrect)
The test code is attached
You can’t use “DengXian”
To use “Deng” or “simsun”(C:\Windows\Fonts\Deng.ttf or C:\Windows\Fonts\simsun.ttc file name)
The pagination is currently correct
But there are differences from Excel print Preview
The difference is embodied in the position of “Page1, Page2, Page3, Page4, Page5”
Please refer to the attached code and screenshot for details.Test.zip (6.9 MB)

Please help to correct:
1: PageX display position
2: Automatically match fonts inside Aspose.Cells

@Diego2020,

Thanks for the sample code, output files and screenshots.

We need to investigate your issue thoroughly based on your resources files. We have logged a ticket with an id “CELLSNET-47532” for your issue. We will look into it soon. The ticket is logged as following:
CELLSNET-47532 - Rendering differences comparing with MS Excel print previews

Once we have an update on it, we will let you know.

@Diego2020,

Please do not change the default Font name in the fix v20.7.7, use the code as in the attached archive “NotChangeDefaultFont.zip”, it will be OK.
NotChangeDefaultFont.zip (1.1 KB)

By the way, for your issue/queries :

You can’t use “DengXian”
To use “Deng” or “simsun”(C:\Windows\Fonts\Deng.ttf or C:\Windows\Fonts\simsun.ttc file name)

Actually, Font Name and font file name are different. We use Font Name encoded inside the font file content.

Also, please share the font file “C:\Windows\Fonts\Deng.ttf” on your side. We need to investigate it on our end.

Using the test code you provided, the results are still wrong

The output file and screenshot are attachedToImage.zip (250.8 KB)
Console.WriteLine.png (7.1 KB)

Deng.zip (9.5 MB)
This is the Deng.ttf file

@Diego2020,
Please do the following steps and let us know your feedback:

  1. Add code to print the Aspose.Cells version.
...
Console.WriteLine("Aspose.Cells version :" + Aspose.Cells.CellsHelper.GetVersion());
Console.WriteLine("DPI :" + Aspose.Cells.CellsHelper.DPI);
...
  1. Do not change the source file “test.xlsx” anyway. Until now, I can see at least two versions of source file “test.xlsx” included in your shared files.

  2. Share your total project, with the output images, pdf file and the console output of a single run. In the other word, the output should be sync.

The code was tested with 20.7.7
I didn’t have to change the default font and I got it right
Thank you for following up on this issue

@Diego2020,
We are glad to know that you have got it right. Should you have any issue with Aspose.Cells API, feel free to contact us. We will be glad to assist you.

@Diego2020,

It will be helpful if you can share why you got the wrong results with the fix v20.7.7.