Hey guys,
I'm having trouble finding this one.
my situation:
- SDK 2.0
- no template spreadsheet
- C# 4.0 in VS2010
my problem:
Certain data in the excel files I want to build exists in DateTime format. As I don't wan't to use just strings (stringed datetimes can't be sorted properly) I want to set the cells that contain DateTime to a format of my choosing as I would do in excel.
To my understanding I have to use a Stylesheet to get to that point. I've been browsing the web for a while now to find someone who has a simple explanation to this problem, but it 's seems that it is hard to find.
I already have a spreadsheet in mem, with the ability to add data, through SheetData. the only thing I'm missing is the formatting/styling of the cells.
this is how far I got:
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument doc = SpreadsheetDocument.Create("test.xlsx", SpreadsheetDocumentType.Workbook);
WorkbookPart wbPart = doc.AddWorkbookPart();
wbPart.Workbook = new Workbook();
SheetData data = new SheetData(
new Row(...etc));
WorksheetPart wsPart = wbPart.AddNewPart<WorksheetPart>();
wsPart.Worksheet = new Worksheet(data);
Sheets sheets = doc.WorkbookPart.Workbook.AppendChild<Sheets>(new Sheets());
Sheet sheet = new Sheet() { Id = doc.WorkbookPart.GetIdOfPart(wsPart), SheetId = 1, Name = "TestSheet" };
sheets.Append(sheet);
wbPart.Workbook.Save();
doc.Close();
where and how can I add simple additions to style like date time (ex, "dd-MM-yyyy"), and maybe more advanced styling later on ?
I hope I was specific enough :) in the meanwhile I'll keep looking...
THX !!!