alias hbin me

Microsoft Excel Issues "File error: data may have been lost"

Last week, We involve a function for users to exports their orders into a spreadsheet document.

We using the spreadsheet gem to modify an existing template spreadsheet. But when opening the modified spreadsheets by Microsoft Excel, it issues an error:

File error: data may have been lost

After some google search, I was answered to set the encoding explictly:

Spreadsheet.client_encoding = 'UTF-16LE'

But it doesn’t works, WTF!

Finally, I decide to create a new spreadsheet and set cell format by hand instead of modify the existing template spreadsheet document. It’s a painful task. The spreadsheet comes up just fine without error.

Even though it doesn’t elegant, we can get ride of that annoying error.