Hi-
How do you add a Date/Time to a cell and format it as a date/time?
Thanks
-Thomas
// Create a workbook object
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Get the "A1" cell and set value for it
CellRange range = sheet.Range["A1"];
range.Value = "2023-10-10 09:45";
// Set the format of cell A1 as date
range.NumberFormat = "yyyy";
//range.NumberFormat = "yyyy-mm-dd";
// Set AutoFitColumns for "A1" cell
range.AutoFitColumns();
// Save the modified Excel file
workbook.SaveToFile(@"../../output/output.xlsx", ExcelVersion.Version2013);
// Close the workbook
workbook.Dispose();