你查一下NPOI
好吧,这个没的说。NPOI,简简单单搞定~
You can use the DLL 'EPPlus', The below is a sample URL for your reference.
http://addisonl.blogspot.hk/2013/04/create-excel-xlsx-via-epplus-epplus.html
可以用NPOI来实现,在同一个workBook中创建多个sheet即可。这里贴一段实现的代码:
private void buttonTest_Click(object sender, EventArgs e) { HSSFWorkbook workBook = new HSSFWorkbook(); //ISheet sheetA = workBook.CreateSheet("sheetA"); //ISheet sheetB = workBook.CreateSheet("sheetB"); createSheet(workBook,"SheetA"); createSheet(workBook,"SheetB"); createSheet(workBook,"SheetC"); string path = Application.StartupPath + @"\test.xls"; if (File.Exists(path)) { File.Delete(path); } using (FileStream file = new FileStream(path, FileMode.Create)) { workBook.Write(file); //创建Excel文件。 file.Close(); } MessageBox.Show("OK"); } private ISheet createSheet(HSSFWorkbook workBook, string sheetName) { ISheet sheet = workBook.CreateSheet(sheetName); IRow RowHead = sheet.CreateRow(0); for (int iColumnIndex = 0; iColumnIndex < 10; iColumnIndex++) { RowHead.CreateCell(iColumnIndex).SetCellValue(Guid.NewGuid().ToString()); } for (int iRowIndex = 0; iRowIndex < 20; iRowIndex++) { IRow RowBody = sheet.CreateRow(iRowIndex + 1); for (int iColumnIndex = 0; iColumnIndex < 10; iColumnIndex++) { RowBody.CreateCell(iColumnIndex).SetCellValue(DateTime.Now.Millisecond); sheet.AutoSizeColumn(iColumnIndex); } } return sheet; }
you can use the dll "aspose.excel" or "aspose.cells"
将数据源都读出来,然后在内存里组织,然后流文件写出来~~
直接用用odbc 操作excel数据库就可以了。一个sheet相当于一个表。和操作一般数据库一样的。