Hi,
how to use the alignment value "Infragistics.Excel.HorizontalCellAlignment.CenterAcrossSelection". This is exactly the functionality I need. I'm exporting an excel and I need to place a heading that is centered across 3 to n columns. The problem is that I have to use wrapping and autoheight. When I use MergedCellsRegion autoheight combined with wrapping it will not place my multiline text in a proper way. Excel sets the height of this line alway to the size of the first line so that all other lines are hidden. So CenterAcrossSelection could be the solution, but I don't know how to use. I can't find a property or method to set range or selection of multiple cells.
Thank you for any help,
Michael
Thanks!
Yes it seems you're right. Sorry about that. You can use the CenterAcrossSelection alignment by setting that alignment on a set of horizontally adjacent cells, one of which being the cell with the value you want to center:
Workbook workbook = new Workbook(WorkbookFormat.Excel2007);Worksheet worksheet = workbook.Worksheets.Add("Sheet1");
WorksheetRow row = worksheet.Rows[0];row.Cells[0].Value = "Centered Text";for (int i = 0; i < 10; i++) row.Cells[i].CellFormat.Alignment = HorizontalCellAlignment.CenterAcrossSelection;
This is a good question that was never answered. How do you use the CenterAcrossSelection horizontal alignment?
This looks like it may be a limitation of Excel. I just opened a new workbook in Excel 2007, merged 2 cells, and enabled Wrap Text. After typing in text which wraps and hitting enter, the cell remains the height of one line of text. When I go to a single cell, enable Wrap Text, type in text which wraps, and hit enter, the row automatically sizes to a larger size. It seems Excel does not auto-size row height based on merged cell heights.