导入excel问题
DataTable dt = new DeceasedManage().BookDetail_Query(from, to);
int rows = dt.Rows.Count;//行数
int columns = dt.Columns.Count;//列数
Workbook book = new Workbook();
Worksheet sheet = new Worksheet("sheet1");
//设置标题
sheet.Cells[0, 0] = new Cell("登记表");
//设置列名
for (int i = 0; i < columns; i++)
{
sheet.Cells[1, i] = new Cell(dt.Columns[i].ColumnName);
}
//导入值
string value = "";
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < columns; c++)
{
value = dt.Rows[r][c].ToString();
sheet.Cells[r + 2, c] = new Cell(value);
}
}
book.Worksheets.Add(sheet);
string name = DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss");
book.Save(@"E:\" + name + ".xls");
在Save的时候有异常,异常如下:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
指定的参数已超出有效值的范围。
参数名: SATSectorIndex
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: SATSectorIndex
源错误:
执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: SATSectorIndex]
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.GetSATSectorID(Int32 SATSectorIndex) +183
ExcelLibrary.Office.CompoundDocumentFormat.SectorAllocation.LinkSectorID(Int32 sectorID, Int32 newSectorID) +164
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.AllocateMSATSector() +242
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.AllocateSATSector() +316
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.GetSATSectorID(Int32 SATSectorIndex) +124
ExcelLibrary.Office.CompoundDocumentFormat.SectorAllocation.LinkSectorID(Int32 sectorID, Int32 newSectorID) +164
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.AllocateMSATSector() +242
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.AllocateSATSector() +316
ExcelLibrary.Office.CompoundDocumentFormat.MasterSectorAllocation.GetSATSectorID(Int32 SATSectorIndex) +124
...全文
相关推荐
excel导入外部数据出现问题的成因及解决方案
Excel 导入外部数据出现问题的成因及解决方案Excel 导入外部数据是一种非常常用的数据管理方式,能够方便我们对数据进行查询和分析。
Navicat for MySql 导入EXCEL中文乱码问题解决
### Navicat for MySQL 导入Excel中文乱码问题解决#### 一、问题背景在使用Navicat for MySQL工具进行数据导入时,经常会出现中文乱码的问题,尤其是在处理Excel
Excel导入数据库时出现的文本截断问题解决方案
在使用Excel进行数据库导入时,有时会遇到一种常见的问题,即文本截断问题。这个问题表现为导入的数据行只显示部分信息,而不是完整的数据。这通常发生在Excel数据与数据库目标字段的数据类型不兼容时。
Web方式下将数据从 Excel 导入到 SQL Server中遇到的问题及其解决方法
在Web环境下,将数据从Excel导入到Microsoft SQL Server数据库是一个常见需求,这个过程可能会遇到多种问题。
解决Java导入excel大量数据出现内存溢出的问题
在进行大数据量处理时,尤其是涉及到文件导入导出的场景,Java开发者可能会面临一个常见的难题——内存溢出。本文将探讨在Java中导入Excel文件时遇到的内存溢出问题,并提供一种有效的解决方案。


