0

I wrote a script that generates excel files. In those files, I add images inside cells. I set the width of the images cell by calculating the total images width.

Here is how it looks in MS Excel:

enter image description here

And here's how it looks in Google Sheets (same file): enter image description here

As you can see, the width of the cell is smaller than the image in Google Docs, but in MS Excel it's the correct size.

Looking at she sheet1.xml of the original file, I can see:

<cols>
    <col min="1" max="1" width="10" customWidth="1"/>
    <col min="2" max="2" width="10" customWidth="1"/>
    <col min="3" max="3" width="12.1" customWidth="1"/>
    <col min="4" max="4" width="20.050541516245488" customWidth="1"/>
    <col min="5" max="5" width="10" customWidth="1"/>
    <col min="6" max="6" width="14.3" customWidth="1"/>
</cols>

And in the new file (after uploading to google, I downloaded it as xlsx) I see:

<cols>
    <col customWidth="1" min="1" max="2" width="7.78"/>
    <col customWidth="1" min="3" max="3" width="9.44"/>
    <col customWidth="1" min="4" max="4" width="15.56"/>
    <col customWidth="1" min="5" max="5" width="7.78"/>
    <col customWidth="1" min="6" max="6" width="11.11"/>
    <col customWidth="1" min="7" max="26" width="8.33"/>
</cols>

Google changed the column sizes. Why, and how can I solve this?

Links:

  • How are you converting the xlsx file to Google Sheets format? – Rubén Jan 11 at 17:05
  • @Rubén uploading it to drive or even just viewing the xlsx file via an android device. – HTMHell Jan 11 at 23:06
0

It's not possible.

The above is because

  1. Google Sheets and Microsoft Excel use different unit of measure to set the cell dimensions. See Is there a column width bug in Google sheets?
  2. There is no way for end-users to change the way that Google convert Excel files to Google Sheets format

One workaround is to make another script that replicates what is done by the script that you use to creates the Excel but to create the Google Sheets spreadsheet.

Another workaround might be to use Google Apps Script to adjust the columns sizes.

  • One thing I don't understand is why is it getting converted wrong? If they use a different unit of measure when they convert the xlsx file, shoulldn't it still be the correct size? – HTMHell Jan 11 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.