Hello, I am struggling with a minor annoying issue when trying to save a worksheet. Basically, I am placing string values into cells that start with 0 ex: "012345". I then try to save the workbook to a local directory and the zero is being removed. I understand this behavior being desired for numeric values but I am specifically formatting this cell as text, in which case I expect the string value to be saved exactly as it is written. Am I missing something? Do I need to format the columns? I have attached the resulting file as well as a screenshot showing values in watch window just prior to save. Here is a sample of my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Spreadsheet;
namespace KendoSpreadsheetPaddedZeroIssue.Controllers
{
public class SpreadsheetController : Controller
{
public ActionResult SaveSpreadsheet()
{
Workbook resultWorkBook = new Workbook();
resultWorkBook.AddSheet();
Worksheet resultWorkSheet = resultWorkBook.Sheets[0];
resultWorkSheet.ShowGridLines = true;
resultWorkSheet.Name = "test1";
resultWorkBook.ActiveSheet = "test1";
List < Cell > cellItems = new List<Cell>();
cellItems.Add(new Cell() {Index = 0, Format = "@", Value = "01234", Bold = false, FontSize = 13, TextAlign = "center", VerticalAlign = "center" });
cellItems.Add(new Cell() {Index = 1, Format = "@", Value = "05678", Bold = false, FontSize = 13, TextAlign = "center", VerticalAlign = "center" });
Row testRow = new Row() { Index = 0, Height = 20, Cells = cellItems };
Worksheet testWorkSheet = resultWorkBook.Sheets[0];
testWorkSheet.AddRow(testRow);
resultWorkBook.Save(@"somepathonmydesktop\Test.xlsx");
return View("Index");
}
}
}