using CellFormatting event.How can i setup borders for cells .
BorderStyles border = new BorderStyles();
border.Color = Color.Black;
border.Weight = 1;
border.LineStyle = LineStyle.Continuous;
border.PositionType = PositionType.Bottom;
How can i use this, cause somethng like that :
e.CellStyleInfo.Borders = border;
doesn't work.
In exportML were e.ExcelStyleElement.Borders.Add function, cant find how this must work.
16 Answers, 1 is accepted
http://www.telerik.com/help/winforms/radgridview-exporting-data-how-to-add-header-and-footer.html or from search cause error.
http://www.telerik.com/help/winforms/radgridview-exporting-data-how-to-add-header-and-footer.html or from search cause error.***
Thank you for writing.
To set the borders, you need to create an object of type CellBorders and assign it to the CellStyleInfo.Borders property. Note that the ExportVisualStyles property of the GridViewSpreadExport should be set to true.
Alternatively, you can use the SpreadProcessing API and work with the workbook.
In regards to inserting rows, again you can utilize the SpreadProcessing API. In this case, you can use the Workbook created event of the renderer, to get the workbook once it is cooked. From there you can perform any manipulations you need.
Here is an example:
private void radButton1_Click(object sender, EventArgs e){ GridViewSpreadExport exporter = new GridViewSpreadExport(radGridView1); exporter.CellFormatting += exporter_CellFormatting; exporter.ExportVisualSettings = true; SpreadExportRenderer renderer = new SpreadExportRenderer(); renderer.WorkbookCreated += renderer_WorkbookCreated; exporter.RunExport(@"D:\asd.xlsx", renderer);}void renderer_WorkbookCreated(object sender, WorkbookCreatedEventArgs e){ Worksheet sheet = (Worksheet)e.Workbook.ActiveSheet; if (sheet.Rows.CanInsert(0,1)) { RowSelection selection = sheet.Rows[0]; selection.Insert(); } CellIndex from = new CellIndex(0, 0); CellIndex to = new CellIndex(0, 1); CellSelection selection1 = sheet.Cells[from, to]; selection1.Merge(); selection1.SetValue("lqlqlq");}void exporter_CellFormatting(object sender, Telerik.WinControls.Export.CellFormattingEventArgs e){ CellBorders borders = new CellBorders(); borders.Top = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red)); borders.Bottom = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red)); borders.Right = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red)); borders.Left = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red)); e.CellStyleInfo.Borders = borders;}I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
Regards,
Stefan
Telerik
ThemableColor.FromArgb(0, 120, 120, 120);Regards,
Stefan
Telerik
if (sheet.Rows.CanInsert(0, 1))
{
RowSelection selection = sheet.Rows[0];
selection.Insert();
}
CellIndex from = new CellIndex(0, 0);
CellIndex to = new CellIndex(0, 16);
CellSelection selection1 = sheet.Cells[from, to];
selection1.Merge();
selection1.SetValue("Перечень разных сборов и прочих поступлений.");
selection1.SetHorizontalAlignment(RadHorizontalAlignment.Center);
selection1.SetFontSize(24);
Regards,
Stefan
Telerik
This part deals that.
if (sheet.Rows.CanInsert(0, 1))
{
RowSelection selection = sheet.Rows[0];
selection.Insert();
}
CellIndex from = new CellIndex(0, 0);
CellIndex to = new CellIndex(0, 16);
CellSelection selection1 = sheet.Cells[from, to];
selection1.Merge();
selection1.SetValue("Перечень разных сборов и прочих поступлений.");
selection1.SetHorizontalAlignment(RadHorizontalAlignment.Center);
selection1.SetFontSize(24);
if (sheet.Rows.CanInsert(0, 1))
{
RowSelection selection = sheet.Rows[0];
selection.Insert();
}
After row insert im getting this strange merges on the summary rows.
My guess for such behavior is if you use incorrect indexes where you insert and where you merge cells. You need to make sure you insert the row at the precise position where you want it, and then, to select the desired cells and merge them.
More about rows and column in RadSpreadProcessing you can find in this documentation section: http://www.telerik.com/help/winforms/spreadprocessing-working-with-rows-and-columns-what-is-row-column.html
And the following section discusses cells and their usage: http://www.telerik.com/help/winforms/spreadprocessing-working-with-cells-what-is-cell.html
Merging cells discussed here: http://www.telerik.com/help/winforms/spreadprocessing-features-merge-unmerge-cells.html.
If you still experience issues, you can send a small sample (using a support ticket, where attachments are allowed) depicting the issue you have, and we will look into it.
Regards,
Stefan
Telerik
To workaround, the issue one can insert the row after the export operation is finished and the file is closed, by opening the file with the format provider and introducing the necessary changes.
Regards,
Stefan
Telerik
