下面是一些代码,用于将SpreadsheetGear for .NET中的 A列和C列格式化为文本,其具有类似于Excel的API-除了SpreadsheetGear的键入频率通常更高之外。弄清楚如何将其转换为与Excel / COM配合使用应该不太困难:IWorkbook workbook = Factory.GetWorkbook();IRange cells = workbook.Worksheets[0].Cells;// Format column A as text.cells["A:A"].NumberFormat = "@";// Set A2 to text with a leading '0'.cells["A2"].Value = "01234567890123456789";// Format column C as text (SpreadsheetGear uses 0 based indexes - Excel uses 1 based indexes).cells[0, 2].EntireColumn.NumberFormat = "@";// Set C3 to text with a leading '0'.cells[2, 2].Value = "01234567890123456789";workbook.SaveAs(@"c:\tmp\TextFormat.xlsx", FileFormat.OpenXMLWorkbook);