我想做一个windows表单应用程序。你可以在文本框中写入文本,当你按下一个按钮时,应用程序会创建一个excel文件,并从文本框中写入文本。
发布于 2013-08-20 13:11:46
这个答案中列出了很多库:What is a simple and reliable C library for working with Excel files?
此外,"ExcelFormat库“是基本的,但听起来它可以做你需要的一切。它是免费的,使用起来很简单。
Number Duck是我创建的一个商业库。
发布于 2014-06-02 04:05:47
这是一段取自https://code.google.com/p/excellibrary/的C#代码,在VC ++中播放这段代码并使其工作。:)语法是不同的,但如果你仔细想想,你会发现它们都是一样的。;)首先,您必须下载ExcelLibrary.dll文件并将其添加到参考项目中。然后添加这两行:使用名称空间ExcelLibrary::CompoundDocumentFormat;使用名称空间ExcelLibrary::SpreadSheet;
本项目目标是提供一个本地.NET解决方案来创建、读取和修改
Excel files without using COM interop or OLEDB connection.目前实现的是.xls (BIFF8)格式。将来还可能支持.xlsx (Excel2007)。
Example code:
//create new xls file
string file = "C:\\newdoc.xls";
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("First Sheet");
worksheet.Cells[0, 1] = new Cell((short)1);
worksheet.Cells[2, 0] = new Cell(9999999);
worksheet.Cells[3, 3] = new Cell((decimal)3.45);
worksheet.Cells[2, 2] = new Cell("Text string");
worksheet.Cells[2, 4] = new Cell("Second string");
worksheet.Cells[4, 0] = new Cell(32764.5, "#,##0.00");
worksheet.Cells[5, 1] = new Cell(DateTime.Now, @"YYYY\-MM\-DD");
worksheet.Cells.ColumnWidth[0, 1] = 3000;
workbook.Worksheets.Add(worksheet);
workbook.Save(file);
// open xls file
Workbook book = Workbook.Load(file);
Worksheet sheet = book.Worksheets[0];
// traverse cells
foreach (Pair<Pair<int, int>, Cell> cell in sheet.Cells)
{
dgvCells[cell.Left.Right, cell.Left.Left].Value = cell.Right.Value;
}
// traverse rows by Index
for (int rowIndex = sheet.Cells.FirstRowIndex;
rowIndex <= sheet.Cells.LastRowIndex; rowIndex++)
{
Row row = sheet.Cells.GetRow(rowIndex);
for (int colIndex = row.FirstColIndex;
colIndex <= row.LastColIndex; colIndex++)
{
Cell cell = row.GetCell(colIndex);
}
}https://stackoverflow.com/questions/16738674
复制相似问题