导入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导入外部数据出现问题的成因及解决方案
Navicat for MySql 导入EXCEL中文乱码问题解决
解决Navicat for MySql 导入EXCEL中文乱码问题解决的有效方法
Excel导入数据库时出现的文本截断问题解决方案
问题 在把Excel导入到数据库中时,发生文本截断问题:即导入的数据每行只有一部分,原始的Excel数据为: 忽略错误 导入SQLServer2008过程中,如果源数据和目标数据类型不匹配会导入失败,所以导入数据时会忽略错误,这次导入题库也是,结果出现了这样的问题: 仔细观察你会发现,题目不完整,最长为25个汉字,很明显这是varchar(50)数据类型,但是源数据和目的数据明明都为文本类型。 不忽略错误 如果不忽略错误,导入数据最后一步会产生这样的问题: 代码如下: -正在执行(错误) 消息 错误0xc02020c5:数据流任务1:在将列“questionContent”(33)
Web方式下将数据从 Excel 导入到 SQL Server中遇到的问题及其解决方法
本文分析了Web方式下将数据从 Excel 导入到Microsoft SQL Server数据库遇到的问题,并提出了相应的解决方法,给出了实现数据校验和导入功能的C#程序。
解决Java导入excel大量数据出现内存溢出的问题
今天小编就为大家分享一篇解决Java导入excel大量数据出现内存溢出的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧


