Skip to content
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

Writing multi line cell content #29

Closed
abrari-ipb opened this issue May 13, 2023 · 2 comments
Closed

Writing multi line cell content #29

abrari-ipb opened this issue May 13, 2023 · 2 comments
Labels
question Further information is requested

Comments

@abrari-ipb
Copy link

Hi, thanks for the great library.

How to properly write a cell with multi-line string content? I have tried using \n and \r\n in the string, but when opened in Excel, it is shown as single line cell (without the \n or \r\n). The weird part is, the cell become multi-line only after I double-clicked (or editing) that cell in Excel.

@salvois salvois added the question Further information is requested label May 13, 2023
@salvois
Copy link
Owner

salvois commented May 13, 2023

Hi @abrari-ipb , this is something I have not tried yet, but I guess you may need rich text content to insert line breaks. My library currently supports only plain text. I'll double check and let you know.
Thanks,
Salvo

@abrari-ipb
Copy link
Author

Thanks for your response. After fiddling around, I found that setting alignment with wrapText: true make line break works in Excel.

var wrapTextStyle = XlsxStyle.Default.With(new XlsxAlignment(wrapText: true));
var content = "multi\nline\nstring";
xlsxWriter.Write(content, wrapTextStyle);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants