I have this Excel file:
(You can see the cell names (or codes) signed with the red color).
I search a way to read the data on this Excel template that, in future, will be in these cells. I think of to use the cell code, but I don't know how. I had tried in this way:
public partial class CaricaDocumento : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Upload();
}
protected void Upload()
{
FileStream stream = File.Open("C:\\TEMPLATE_P6.xlsx", FileMode.Open, FileAccess.Read);
// Reading from a OpenXml Excel file (2007 format; *.xlsx)
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
// Data Reader methods
while (excelReader.Read())
{
int i = excelReader.GetOrdinal("AO10"); // doesn't works: throw a System.NotSupportedException
var s = excelReader.GetValue(i);
System.Console.WriteLine(s.ToString());
}
//Free resources
excelReader.Close();
}
}
I didn't find nothing simple to use. I have read about some 3rd-party libraries, but I prefer to avoid using them (if it is possible).