Hi,
In the export to Excel from Kendo grid have problem.
Can I put one field as textual, one as a date and all others as a number? When exporting, they all come to me as numbers, so I have a problem with XLSX that eats the first 0, and I would like to put that field in textual.
This is my code:
SpreadDocumentFormat exportFormat = SpreadDocumentFormat.Xlsx;
Action<ExportCellStyle> cellStyle = new Action<ExportCellStyle>(ChangeCellStyle);
Action<ExportRowStyle> rowStyle = new Action<ExportRowStyle>(ChangeRowStyle);
Action<ExportColumnStyle> columnStyle = new Action<ExportColumnStyle>(ChangeColumnStyle);
List<ExportColumnSettings> columnsData = new List<ExportColumnSettings>();
//columnsData.Add(new ExportColumnSettings() { Field = "RB", Title = "R.b.", Hidden = false, Format = null });
columnsData.Add(new ExportColumnSettings() { Field = "BR", Title = "BR", Hidden = false, Format = null });
columnsData.Add(new ExportColumnSettings() { Field = "Date", Title = "Date", Format = "{0:MM/dd/yyyy}", Hidden = false });
columnsData.Add(new ExportColumnSettings() { Field = "Name", Title = "Naziv i sjedište", Format = null, Hidden = false });
columnsData.Add(new ExportColumnSettings() { Field = "OIB", Title = "OIB", Format = "@", Hidden = false });
columnsData.Add(new ExportColumnSettings() { Field = "Iznos", Title = "Iznos rn.", Format = null, Hidden = false });
and my settings for Cell style:
private void ChangeCellStyle(ExportCellStyle e){
bool isHeader = e.Row == 0;
SpreadBorder border = new SpreadBorder(SpreadBorderStyle.Thin, new SpreadThemableColor(new SpreadColor(0, 0, 0)));
SpreadCellFormat format = new SpreadCellFormat
{
ForeColor = isHeader ? SpreadThemableColor.FromRgb(50, 54, 58) : SpreadThemableColor.FromRgb(0, 0, 0),
VerticalAlignment = SpreadVerticalAlignment.Center,
//NumberFormat = "dd.MM.yyyy.",
//NumberFormat = "@",
TopBorder = border,
BottomBorder = border,
};
e.Cell.SetFormat(format);
}
Thnx,
Andrea