Bug 170397 - XLSX Import: Manual column widths ignored and auto-shrunk to minimum content width (AutoFit) during rendering
Summary: XLSX Import: Manual column widths ignored and auto-shrunk to minimum content ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.3.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: PDF-Export
  Show dependency treegraph
 
Reported: 2026-01-20 07:43 UTC by Shiwei He
Modified: 2026-01-28 19:45 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
An example .xlsx file with manually set column widths. (8.67 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2026-01-23 06:37 UTC, Shiwei He
Details
The column width was shrunk. (65.56 KB, image/png)
2026-01-23 06:42 UTC, Shiwei He
Details
Column widths are squeezed when cells are merged. (97.50 KB, application/vnd.ms-excel)
2026-01-27 05:51 UTC, Shiwei He
Details
HTML Source Generated by LibreOffice Showing Column Width Squeezing with Merged Cells (537.75 KB, text/html)
2026-01-27 05:53 UTC, Shiwei He
Details
This file is intended to explain the issue where column widths are shrunk. (879.88 KB, application/pdf)
2026-01-27 05:54 UTC, Shiwei He
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shiwei He 2026-01-20 07:43:42 UTC
Description:
I would like to report a rendering/import issue regarding column widths in Excel (.xlsx) files.
When opening or previewing an uploaded Excel file, the application seems to ignore the manually set column widths and forces an "AutoFit" behavior based on the content length.

Steps to Reproduce:
1. Create a new spreadsheet in **Microsoft Excel** and save it as `test.xlsx`.
2. In a column, enter a short text string (e.g., `"Test"`).
3. Manually expand the column width to a value significantly wider than the content  
   (e.g., set the width to **20 or 30**).
4. *(Optional but recommended)* Create merged cells in adjacent rows to better expose layout issues.
5. Convert the Excel file to PDF using LibreOffice in headless mode with the following command:
   ```bash
   soffice --headless --convert-to pdf test.xlsx

Actual Results:
The column width in the generated PDF is automatically reduced to fit the text content, as if AutoFit were applied, ignoring the manually defined column width set in Excel.

Expected Results:
The column width in the output PDF should preserve the original width defined in Excel, regardless of the content length.


Reproducible: Always


User Profile Reset: No

Additional Info:
## Version of LibreOffice

sh-4.4# /opt/libreoffice7.5/program/soffice --version
LibreOffice 7.5.3.2 9f56dff12ba03b9acd7730a5a481eea045e468f3

## System info

Report generated on Tue Jan 20 07:35:37 AM UTC 2026

========================================
 SYSTEM INFORMATION
========================================
Kernel: Linux 6.17.8-orbstack-00308-g8f9c941121b1
Hostname: 320dcd6f6c2c
NAME="SLES"
VERSION_ID="15.7"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP7"
CPE_NAME="cpe:/o:suse:sles:15:sp7"

========================================
 DISPLAY ENVIRONMENT
========================================
XDG_SESSION_TYPE: Unknown
XDG_CURRENT_DESKTOP: Unknown
DESKTOP_SESSION: Unknown
GDK_BACKEND: Unset
QT_QPA_PLATFORM: Unset

========================================
 GRAPHICS / GPU
========================================

> Command: lspci (NOT FOUND)

> Command: glxinfo (NOT FOUND)

========================================
 LIBREOFFICE VERSION
========================================
Standard 'libreoffice' or 'soffice' command not found in PATH.

========================================
 LO SPECIFIC ENV VARS
========================================

========================================
 JAVA
========================================

> Command: java -version
openjdk version "21.0.7" 2025-04-15 LTS
OpenJDK Runtime Environment SapMachine (build 21.0.7+6-LTS)
OpenJDK 64-Bit Server VM SapMachine (build 21.0.7+6-LTS, mixed mode, sharing)
Comment 1 m_a_riosv 2026-01-21 22:20:15 UTC
Please attach a sample file(s), reduce the size as much as possible without private information, and paste in the answer the information in Menu/Help/About LibreOffice, there is a copy icon.
Comment 2 Shiwei He 2026-01-23 06:37:29 UTC
Created attachment 205141 [details]
An example .xlsx file with manually set column widths.
Comment 3 Shiwei He 2026-01-23 06:42:22 UTC
Created attachment 205142 [details]
The column width was shrunk.

After conversion with LibreOffice in headless mode, the column widths were reduced.
Comment 4 Shiwei He 2026-01-23 06:43:57 UTC
(In reply to m_a_riosv from comment #1)
> Please attach a sample file(s), reduce the size as much as possible without
> private information, and paste in the answer the information in
> Menu/Help/About LibreOffice, there is a copy icon.

Hi Roisv,

Thank you for your attention. I’ve attached the example files.
Comment 5 m_a_riosv 2026-01-23 11:45:35 UTC
I can't reproduce the issue.
Version: 25.8.4.2 (X86_64)
Build ID: 290daaa01b999472f0c7a3890eb6a550fd74c6df
CPU threads: 16; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster; VCL: win
Locale: en-GB (es_ES); UI: en-US
Calc: threaded

Please test in safe mode, Menu/Help/Restart in Safe Mode

If it doesn't work please try updating your LibreOffice versions.
Comment 6 Shiwei He 2026-01-27 05:50:25 UTC
(In reply to m_a_riosv from comment #5)
> I can't reproduce the issue.
> Version: 25.8.4.2 (X86_64)
> Build ID: 290daaa01b999472f0c7a3890eb6a550fd74c6df
> CPU threads: 16; OS: Windows 11 X86_64 (build 26200); UI render:
> Skia/Raster; VCL: win
> Locale: en-GB (es_ES); UI: en-US
> Calc: threaded
> 
> Please test in safe mode, Menu/Help/Restart in Safe Mode
> 
> If it doesn't work please try updating your LibreOffice versions.

Hi Riosv,

Thanks for you reply. I need to clarify that I encountered this issue in headless mode, not in the GUI, so options like Menu → Help → Restart are not available.

Please refer to the newly provided PDF document, which demonstrates that when LibreOffice converts files to HTML in headless mode, it does not handle column width calculation well in cases involving merged cells.

The command I used:
```shell
./soffice --headless  --convert-to html excel.xls
```

The original file has been uploaded as an attachment.
Please refer:
1. explain.pdf
2. column-widths-are-squeezed-when-cells-are-merged-generated-by-soffice.html
3. column-widths-are-squeezed-when-cells-are-merged.xls

I'm looking forward to your response.

BR,
Shiwei
Comment 7 Shiwei He 2026-01-27 05:51:09 UTC
Created attachment 205191 [details]
Column widths are squeezed when cells are merged.

The excel file which demostrate column widths are squeezed when cells are merged.
Comment 8 Shiwei He 2026-01-27 05:53:05 UTC
Created attachment 205192 [details]
HTML Source Generated by LibreOffice Showing Column Width Squeezing with Merged Cells

This is the HTML source code generated after I converted
column-widths-are-squeezed-when-cells-are-merged.xls to HTML using LibreOffice.

The command I used:
soffice --headless  --convert-to html excel.xls
Comment 9 Shiwei He 2026-01-27 05:54:13 UTC
Created attachment 205193 [details]
This file is intended to explain the issue where column widths are shrunk.

This file is intended to explain the issue where column widths are shrunk.
Comment 10 Shiwei He 2026-01-27 05:57:51 UTC
In our product, we use LibreOffice to convert customer-uploaded Excel files into a previewable format. This relies on LibreOffice’s feature for converting Excel files to HTML.

./soffice --headless --convert-to html excel.xls


We hope this issue can be fixed so that the converted HTML renders consistently with the preview in Microsoft Excel.
Thank you very much.
Comment 11 m_a_riosv 2026-01-27 22:47:03 UTC
On GUI mode I can't see the issue saving as HTML happens, but exporting as XHTML works fine, try with it.

There are a long list of issues with HTML, but I don't think it is going to get some attraction to solve them.

Better try with XHTML.