我有一个Telerik radGridView1,我正在将它导出到excel中,但excel文件中没有显示任何边框。那么如何带边框导出它呢?我正在以这种方式输出...
ExportToExcelML export = new ExportToExcelML(this.radGridView1);
export.ExportVisualSettings = true;
export.RunExport(saveFileDialog1.FileName);提前感谢
发布于 2012-10-25 21:52:43
ExcelCellFormatting事件可能会对您有所帮助:
它允许访问单个单元格的SingleStyleElement,允许您进行其他格式设置(添加边框、设置对齐方式、文本字体、颜色、更改单元格值等)。对于与导出的RadGridView相关的每个excel单元格:
void exporter_ExcelCellFormatting(object sender,Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
    if (e.GridRowInfoType == typeof(GridViewTableHeaderRowInfo))
    {
        BorderStyles border = new BorderStyles();
        border.Color = Color.Black;
        border.Weight = 2;
        border.LineStyle = LineStyle.Continuous;
        border.PositionType = PositionType.Bottom;
        e.ExcelStyleElement.Borders.Add(border);
    }
    else if (e.GridRowIndex == 2 && e.GridColumnIndex == 1)
    {
        e.ExcelStyleElement.InteriorStyle.Color = Color.Yellow;
        e.ExcelStyleElement.AlignmentElement.WrapText = true;
    }
}有关详细信息,请单击here。
https://stackoverflow.com/questions/13063382
复制相似问题