-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Text Wrap in Outlook Preview mode #257
Comments
Excel saves files in text mode with \r\n. libxlsxwriter saves in binary mode. Excel can convert it "on the fly" at open, preview mode can't. See #156 . A solution can be with an option changing write mode (from binary to text). |
@sirhvd could you add a small, complete C program that generates a file that demonstrates the issue. Could you also, if possible add a screenshot of the preview in Outlook so that I can try replicate this. |
@jmcnamara Sorry for the late reply. I just using your example code: int main() {
lxw_workbook *workbook = workbook_new("wrap.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_format *wrap_format = workbook_add_format(workbook);
format_set_text_wrap(wrap_format);
worksheet_write_string(worksheet, 0, 0, "Col 1", wrap_format);
worksheet_write_string(worksheet, 0, 1, "Col 2", wrap_format);
worksheet_write_string(worksheet, 1, 0, "First Long long long long long long text", wrap_format);
worksheet_write_string(worksheet, 1, 1, "Second long long long long long long text", wrap_format);
workbook_close(workbook);
return 0;
} I think this problem comes from text/binary mode as @RaFaeL-NN mentions. |
Thanks for the sample code. I think I see what the issue may be. When you set word wrap like this Excel resizes the row automatically when it opens the file. That probably isn't happening in the Outlook preview. Try setting the row height explicitly and see if the result is different: #include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = workbook_new("wrap.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_format *wrap_format = workbook_add_format(workbook);
format_set_text_wrap(wrap_format);
worksheet_write_string(worksheet, 0, 0, "123\n456", wrap_format);
/* Add this line. */
worksheet_set_row(worksheet, 0, 28, NULL);
workbook_close(workbook);
return 0;
} Output in Excel: |
Thank for your reply. |
No. This is a calculation that Excel does at run time. It isn't part of the file format so it cannot be controlled from Libxlsxwriter. The user either has to set the row height explicitly or allow Excel to do it at run time with possible unforeseen actions (like in your case).
In that case I will close this issue since we now know why Outlook Preview behaves differently to Excel in this case. |
Hi @jmcnamara.
I was using the excel files generated from libxlsxwriter library, and upload these file to Outlook mail. (https://outlook.office365.com/)
But I have a small problem when open Excel file in preview mode ( Outlook Mail ).
Text wrap not working in preview mode, but in Windows desktop, it's working fine.
To make text wrap work in preview mode, I must open the excel file then save it again.
I hope you will check it out.
Thank you
Cheers!
The text was updated successfully, but these errors were encountered: