Column width is not the same on my workstation and on the production server

Hi,
I set ws.Cells.Columns[0].Width = 17;
It works on my Workstation, but when I publish the web application to a server. The resulting Excel file as a column witdh of 16.85.

Any idea?
Regards,

Hi Jean,


Thank you for contacting Aspose support.

If you are using same revision of the API on both of the machines then please compare the display settings as shown in the attached snapshot. If both machines have different display size settings then make them alike and re-run the test.

Hi,

Thank you for your answer.

I use the exact same cells.dll on my Workstation (Windows 10) and on the server (Windows 2003 server). The display settings are the same on both computer (see screenshot below).

So the problem remains the same.

Any other idea?

Regards,

Hi Jean,


Thank you for writing back.

If the display settings are same then could you please check if the font used to format the particular cell (or used as a default font for the spreadsheet) is available on Windows Server 2003. I recall, there are a few default fonts missing in Windows Server 2003 environment. Please note, Aspose.Cells APIs require the fonts used in the spreadsheet to be available in the environment to calculate the glyph width and height and consequently the width & height of the cell.

Hi,
Thank you for your answer.
I have allready installed the ‘calibri’ font on the server. So the font is installed on both computers.
Then, I think we have to look for another reason.

Maybe another information that can help. in fact, on the server, the columns width is just the next smaller value. For example, if I set 17 in the C# code, the width will be 17 on my Workstation an 16,86 on the server. If I set 45 in C#, the width will be 45 on my Workstation and 44.86 on the server. If I set 7 in C#, the width will be 7 on my Workstation and 6.86 an the server. It is always the next smaller value on the server, whatever value I set.

Just a question about your answer. You tell me that if I set the colomn width like that: ‘ws.Cells.Columns[0].Width = 17;’, in fact the widht can be set of another value depending on the font that is used. Is it right? But I need to set a fixed size to some column. Is it impossible with Aspose product?

Regards,

Hi Jean,


Thank you for the additional information, however, we require following details to further look into the matter.

  • Which version of Aspose.Cells for .NET you are currently using?
  • What is the target .NET Framework?
  • Have you tried the same case against the most recent release of Aspose.Cells for .NET API, that is; 8.6.1 at the moment? If not, please give a try to the latest version and feed us back with your results. If you are getting the same/expected results with the latest release then the said behavior could be caused due to some bug in your current version of the API.
  • Are you comparing the column widths in Excel application or rendering the resultant spreadsheet to PDF or images?
  • Are you loading a pre-built spreadsheet? If yes, please share the spreadsheet in question. Also state if you are seeing the same behavior with every spreadsheet or just some specific ones. In case you are building the spreadsheet from scratch then please share the complete code (preferably a simple standalone console application) for further review.

Regarding my previous comments about the required fonts, this is true if you are rendering the spreadsheets, that is; converting the spreadsheets to PDF, XPS or image formats. In this case, if the required fonts (used in the spreadsheet) should be available to the Aspose.Cells APIs otherwise they will be substituted with the available ones, and consequently the size of the text/value will change. Moreover, if you are calling the AutoFitRows/Columns method, the size of the cell will be changed as well.

Hi Babar,

Thank you for your answer.

I have made some more testings to write my answer to you, and I don’t have the problem anymore?!?

The only thing that changed is the screen resolution on the server. Indeed, when you asked me to check the font-size settings, I asked the local network administrator to log on physically to the server, to check the settings. As I use remote desktop, I was not sure to see the real settings. He told that the font size was ok (100%). He also told me that he changed the screen resolution from 800600 to 1024768.

So, I think that the low local screen resolution on the server was the explanation for my columns width problem.

Strange isn’t it! What do you think?

Info:

  • I currently use Aspose.cells 7.4.0.0 and target .net Framework is 4

Do not hesitate to contact me if you need further information.

Regards,

Something else. Except when I have joined an image, all the carriage returns have disapeared from my replies in this post.
I use IE 11
Regards,

Enviromatic:
Hi Babar,

Thank you for your answer.

I have made some more testings to write my answer to you, and I don’t have the problem anymore?!?

The only thing that changed is the screen resolution on the server. Indeed, when you asked me to check the font-size settings, I asked the local network administrator to log on physically to the server, to check the settings. As I use remote desktop, I was not sure to see the real settings. He told that the font size was ok (100%). He also told me that he changed the screen resolution from 800600 to 1024768.

So, I think that the low local screen resolution on the server was the explanation for my columns width problem.

Strange isn’t it! What do you think?

Info:

  • I currently use Aspose.cells 7.4.0.0 and target .net Framework is 4

Do not hesitate to contact me if you need further information.

Regards,


Hi again,

What I understand from your post is that you are able to resolve the said issue by increasing the resolution on the problematic machine. Based on this understanding, I have performed a few tests by changing the resolution of my machine (Windows 7 Home Premium x64) and saving the spreadsheets with column width as 17. When I checked the resultant spreadsheets in Excel (on same resolution where they were produced as well as changing it back to original) I am seeing the column widths set to 17, as expected. Please note, I have used the latest version of Aspose.Cells for .NET 8.6.1.1 for the testing, and it leads me to believe that the said problem could be an anomaly of your current version of the API. You can further confirm it by executing the test case against the latest version (download link shared above).

C#

var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];
var cells = worksheet.Cells;
cells.Columns[0].Width = 17;
workbook.Save(“C:/temp/800x600.xlsx”, SaveFormat.Xlsx);

Enviromatic:
Something else. Except when I have joined an image, all the carriage returns have disapeared from my replies in this post. I use IE 11 Regards,

Thank you for raising this issue. We have reported it to the Web Team for further investigation and correction purposes.