unvell / ReoGrid

Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.

Home Page:https://reogrid.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to display full text beyond cell limits?

lotuslakestudio opened this issue · comments

I'm using this software to creat a .xlsx file like this
2
Yet the production of this software is this
1

So, how to get the right format as shown in the first picture?
Thanks in advance.

You have to enable the setting:

Worksheet.EnableSettings(WorksheetSettings.View_AllowCellTextOverflow);

And avoid to set cells background color.

It seems the above code isn't working. The texts are still being trimmed at the cell border.
I'm using Win10, Visual studio 2022 community, .net framework 4.8.

I found the problem. This bug occurs because I introduced another 3rd program to generate .xlsx files, which named "closedxml". When I fill the cells by ReoGrid code, the format is correct.

So if the problem has been resolved, you can consider to close this issue.

Although the origin of the problem has been discovered, I don't know how to solve it. I tried another program "NPOI". The program generated long text beyond cell limits can not be displayed correctly in ReoGrid, either. Can you fix that?
---------------- by NPOI --------------------

XSSFWorkbook workbook = new XSSFWorkbook();
ISheet ws = workbook.CreateSheet("sheet1");            
XSSFRichTextString rts = new XSSFRichTextString("Some text which is very long that exceeds the boundary");
ws.CreateRow(0).CreateCell(0).SetCellValue(rts1);
workbook.Write("c:\\test.xlsx");

Can you please provide the xlsx file?

Another problem found. When I'm using
this.reoGridControl1.CurrentWorksheet.Cells["A1"].Data ="very looooooooong text"
The cell looks good. But if i'm using
unvell.ReoGrid.Drawing.RichText rt = new unvell.ReoGrid.Drawing.RichText(); rt.Regular("very looooooooong text"); this.reoGridControl1.Worksheets[0].Cells["A1"].Data = rt;
The same problem happens. The text beyond cell boundary is trimmed.

I solved this problem finally.

foreach (var sheet in this.reoGridControl1.Worksheets)
 {
       sheet.EnableSettings(WorksheetSettings.View_AllowCellTextOverflow);
       for (int r = sheet.UsedRange.Row; r <= sheet.UsedRange.EndRow; r++)
            for (int c = sheet.UsedRange.Col; c <= sheet.UsedRange.EndCol; c++)                    
                if (sheet.GetCell(r, c) != null && sheet.GetCell(r, c).Data is unvell.ReoGrid.Drawing.RichText)
      (sheet.GetCell(r, c).Data as unvell.ReoGrid.Drawing.RichText).Overflow = true;
}