Sets a cell's content to a DateTime value within an Excel sheet. Allows for the direct assignment of date and time information to a cell.
public void SetCellValue(DateTime date)
date
The DateTime value to be assigned to the cell.
Due to localization, calculation, and other application and usage requirements, it is important to consider the format in which the DateTime value will be displayed in the cell.
using Leadtools;using Leadtools.Document.LEADOffice.Sheet;public void CreateWorkbookFileExample(){// Initialize the workbookvar workbook = LEADWorkbookFactory.Create();// Add a new sheet named "Test"var sheet = workbook.CreateSheet("Test");// Access the first cell (assuming 0-based indexing)var cell = sheet.CreateRow(0).CreateCell(0);// Update the cell's valuecell.SetCellValue("LEADTOOLS");// Style the cellvar cellStyle = workbook.CreateCellStyle();cellStyle.Font = workbook.CreateFont("Arial", 12, FontStyle.Bold, RasterColor.FromKnownColor(RasterKnownColor.Black));cellStyle.BackgroundColor = RasterColor.FromKnownColor(RasterKnownColor.Gray);cellStyle.HorizontalAlignment = HorizontalAlignment.Center;cellStyle.VerticalAlignment = VerticalAlignment.Center;cellStyle.WrapText = TextWrap.Wrap;// Apply the style to the cellcell.SetStyle(cellStyle);// Save the workbook to diskvar filePath = Path.Combine(LEAD_VARS.ImagesDir, @"WorkbookTest.xlsx");workbook.Save(filePath);}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}