我一直在寻找一段时间,似乎无法找到如何做到这一点.我有一张excel表,我正在使用OpenXML阅读.现在正常情况是循环遍历行然后循环遍历单元格以获取值,这很好.但是随着值的增加,我需要单元格的位置,格式为(rowindex,ColumnIndex).我已经设法得到了rowIndex,但似乎无法弄清楚索引列.
我实际上认为这很容易,但显然它不是.
我正在使用 OpenXml 将大数据转换为 Excel,并且我正在使用以下导出到 Excel 类
http://www.codeproject.com/Articles/692092/A-free-Export-to-Excel-Csharp-class-using-OpenXML
下面是我班级中的代码。
public static bool CreateExcelDocumentAsStream(DataSet ds, string filename, System.Web.HttpResponse Response)
{
try
{
System.IO.MemoryStream stream = new System.IO.MemoryStream();
using (SpreadsheetDocument document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook, true))
{
WriteExcelFile(ds, document);
}
stream.Flush();
stream.Position = 0;
Response.ClearContent();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
// NOTE: If you get an "HttpCacheability does not exist" error on the following line, make sure you have
// manually added System.Web to this project's References.
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.AddHeader("content-disposition", "attachment; filename=" + …Run Code Online (Sandbox Code Playgroud)