Different StandardHeight/StandardWidth when run in Session 0 vs Session 1

Hi,

This one is quite a weird and complex one and difficult to replicate but causes massive problems.

Aspose being server-side compatible we run it inside a service; in Windows this gives the process session 0. Here is a quick article explaining sessions in Windows:

However, on a certain hardware Aspose.Slides gives us different (wrong) values for StandardHeight and StandardWdith when run in session 0 as opposed to session 1. This causes the output file to also have its height and width reset to the wrong one!

To test, you can use any Excel Workbook, although I have attached one for convenience.

Running the following code:

var book = new Workbook(“Test.xlsx”);

Console.WriteLine(book.Worksheets[0].Cells.StandardHeight);

Console.WriteLine(book.Worksheets[0].Cells.StandardWidth);

In session 1:

Height: 12.75

Width: 8.42857142857143

This seems to be the correct value.

When running in session 0 I get:

Height: 13.2

Width: 8.3333333333333

To run the program in session 0 you can use the following command as administrator to open up a session 0 session

psexec.exe –s –i 0 cmd.exe

Now the caveat here is that not all hardware we run it on produces the incorrect result. So it would be nice if you could check with engineers what the probable cause of this could be.

Best regards,

Hi,

Thanks for your posting and using Aspose.Cells.

It seems you are running your program on two different machines. The first machine gives different results than second machine. It means it is a font problem. The fonts are not same on both machines. Suppose your excel file uses Arial and your first machine also has Arial, then it will give correct values and if your second machine does not have Arial, then it will give different results.

If your problem is not occurring because of it, then it will be helpful if you could provide some screenshots or preferably a video. It will help us look into your issue more precisely and closely and we will be able to help you asap. Thanks for your cooperation.

Hi,


This is on the same machine but different session id.
If you run the psexec command I detailed in the first post you will see what changing session means.
So it will be accessing the same font folder.

Console.WriteLine(book.Worksheets[0].Cells.Style.Font.Name);

This line will print the same font with both sessions. We have tested with multiple default windows fonts such as Arial, Calibri etc. and each time there’s a difference.

I am not sure how a screenshot or video will help. The only thing it will show is two command prompt windows, with the two different outputs I pasted in my first post.

Best regards,

Hi,

Thanks for your complete description and using Aspose.Cells.

We are afraid we are unable to replicate this issue on our machine by following your steps. Please make sure you are using the latest version:
Aspose.Cells for .NET v8.7.0.2
.

I have attached the screenshots in the pdf format for your reference. As you can see results are correct in both cases.

I have also attached the console application project, please try it at your end and see if you get same or different results.

Here is the code I used in the test project.

C#

string filePath = “F:\Shak-Data-RW\Downloads\Test.xlsx”;

var book = new Workbook(filePath);
Console.WriteLine(book.Worksheets[0].Cells.StandardHeight);
Console.WriteLine(book.Worksheets[0].Cells.StandardWidth);

Cell c = book.Worksheets[0].Cells[“I9”];
Style s = c.GetStyle();

Console.WriteLine(s.Font.Name);

Console.ReadKey();

Hi,


As I said, even on our side the problem only occurs on a specific hardware configuration. It is reproducible each time but only on that specific hardware (on all machines with that hardware configuration).

This is why I am asking you to get information from your engineers about what may be the cause for this issue as it clearly is not happening on every machine. Maybe they can point us to a specific hardware item or a windows configuration which could impact this when running in session 0.


Best regards,

Hi,

Thanks for your posting and using Aspose.Cells.

We have logged this issue in our database for investigation. We will look into it and provide you advice. Once there is some news or fix for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-44249 - Different StandardHeight/StandardWidth when run in Session 0 vs Session 1

Hi,

Thanks for using Aspose.Cells.

We have looked into this issue further and found that this issue is caused by different DPI in the different sessions.

If the DPI is changed, the default column’s width is changed too in MS Excel.

Aspose.Cells works as MS Excel.

If you need to get the same width, please specify the DPI.

Please see the following code.

C#

CellsHelper.DPI = 96;
var book = new Workbook(path + “Test.xlsx”);
Console.WriteLine(book.Worksheets[0].Cells.StandardHeight);
Console.WriteLine(book.Worksheets[0].Cells.StandardWidth);