You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading the above file with FastExcel, cells with string contents behave as expected, whereas cells with numeric contents return zero. In the original file, only some cells have zero contents; most of them have non-zero numbers. So far, I have noticed this problem only with the attached file; FastExcel handles other .xlsx files properly. Here is what the beginning of the file looks like when opened with Microsoft Excel:
Here is what the beginning of the file looks like after processing with the code shown later below:
To demonstrate the problem, I use this C# code in file FastExcelRead.aspx.cs belonging to an ASP.Net web page:
using FastExcel;
using System;
using System.Data;
using System.IO;
namespace TSoar.Developer.SWLab
{
public partial class FastExcelRead : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
{ string sPath = Server.MapPath("~/AppData/ClubFinStat/Historical/2021-11-24/");
DirectoryInfo di = new DirectoryInfo(sPath);
FileInfo[] files = di.GetFiles("Puget+Sound+Soaring+Association_Balance+Sheet*.xlsx", 0);
DataTable dt = new DataTable();
int iNumCols = 0;
using (FastExcel.FastExcel fEx = new FastExcel.FastExcel(files[0], true))
{ Worksheet ws = fEx.Read(1); // There is only one worksheet
foreach (FastExcel.Row r in ws.Rows){
foreach (var cell in r.Cells)
{ iNumCols++; }
break;
}
for (int j = 0; j < iNumCols; j++)
{ dt.Columns.Add("Column " + (101 + j).ToString().Substring(1));
}
foreach (FastExcel.Row r in ws.Rows)
{ DataRow dr = dt.NewRow();
int j = 0;
foreach (var cell in r.Cells)
{ dr[j++] = cell.Value;
}
dt.Rows.Add(dr);
}
}
gv.DataSource = dt;
gv.DataBind();
}
}
}
}
Here is the code in the corresponding FastExcelRead.aspx file:
It is always possible that I am doing something wrong in using the FastExcel package, but I kind of doubt it. A similar problem occurred with this particular .xlsx file when I processed it with ExcelDataReader.DataSet.
The text was updated successfully, but these errors were encountered:
Puget+Sound+Soaring+Association_Balance+Sheet (4).xlsx
When reading the above file with FastExcel, cells with string contents behave as expected, whereas cells with numeric contents return zero. In the original file, only some cells have zero contents; most of them have non-zero numbers. So far, I have noticed this problem only with the attached file; FastExcel handles other .xlsx files properly. Here is what the beginning of the file looks like when opened with Microsoft Excel:
Here is what the beginning of the file looks like after processing with the code shown later below:
To demonstrate the problem, I use this C# code in file FastExcelRead.aspx.cs belonging to an ASP.Net web page:
Here is the code in the corresponding FastExcelRead.aspx file:
It is always possible that I am doing something wrong in using the FastExcel package, but I kind of doubt it. A similar problem occurred with this particular .xlsx file when I processed it with ExcelDataReader.DataSet.
The text was updated successfully, but these errors were encountered: