Are cell width and height in pixels easily available?

99 views
Skip to first unread message

Polly

unread,
Sep 1, 2021, 9:51:29 AM9/1/21
to openpyxl-users

Hi, Team! I see the following xml information for an excel sheet (after decompression):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{00000000-0001-0000-0000-000000000000}"><dimension ref="A1:A7"/><sheetViews><sheetView tabSelected="1" zoomScale="125" workbookViewId="0"><selection activeCell="A8" sqref="A8"/></sheetView></sheetViews><sheetFormatPr baseColWidth="10" defaultColWidth="8.83203125" defaultRowHeight="13" x14ac:dyDescent="0.15"/><cols><col min="1" max="1" width="43.83203125" customWidth="1"/></cols><sheetData><row r="1" spans="1:1" ht="152" customHeight="1" x14ac:dyDescent="0.2"><c r="A1" s="1" t="s"><v>0</v></c></row><row r="3" spans="1:1" x14ac:dyDescent="0.15"><c r="A3" t="s"><v>1</v></c></row><row r="4" spans="1:1" x14ac:dyDescent="0.15"><c r="A4" t="s"><v>2</v></c></row><row r="5" spans="1:1" x14ac:dyDescent="0.15"><c r="A5" t="s"><v>3</v></c></row><row r="6" spans="1:1" ht="64" customHeight="1" x14ac:dyDescent="0.15"/><row r="7" spans="1:1" x14ac:dyDescent="0.15"><c r="A7" t="s"><v>4</v></c></row></sheetData><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>

The information above provides data about the width and height for every cell with data (interestingly, for cells without data width and height above formatting is still preserved when closing and opening the excel sheet but I cannot find it anywhere in the xml files generated during decompression). I was wondering if the above data is already easily accessible in the package or should I create a PR for it?

Screenshot 2021-09-01 at 14.46.34.png

In the example above A6 preserves its formatting when closing/opening file on different machines, but I do not see it in the XML above; Also, it seems like height is not exactly available as number, but nonetheless excel is able to reconstruct the same display so I guess this data is stored somewhere or somehow calculated.

Thanks!

Reply all
Reply to author
Forward
0 new messages