Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Closed Unassigned: Read Excel file in the Server side [15098]

$
0
0
Hi!

I'm having "a small" problem. I need to load the data from a Excel file in a Client computer, and read its contents in the server side...
When i debug, all is fine... but when i publish the website in the server and try to read a file, there are no worksheets (and the FileUpload.PostedFile.FileName only as the File name! In my computer, it as the FullPath and File name!)

Can anyone help me please?

I'm using this code:
{
...
var existingFile = new FileInfo(fuTextFile.PostedFile.FileName);
using (var package = new ExcelPackage(existingFile))
{
ExcelWorkbook workBook = package.Workbook;
if (workBook != null)
{
if (workBook.Worksheets.Count > 0)
{
ExcelWorksheet currentWorksheet = workBook.Worksheets.First();
DataTable dt = new DataTable("Equipamentos");

for (int i = 1; i < 27; i++)
{
Create_Columns(dt, currentWorksheet.Cells[1, i].Value.ToString());
}

for (int rowNumber = 2; rowNumber <= currentWorksheet.Dimension.End.Row; rowNumber++)
{
DataRow dr = dt.NewRow();
for (int i = 1; i < 27; i++)
{
if (currentWorksheet.Cells[rowNumber, i].Value != null)
{
dr[currentWorksheet.Cells[1, i].Value.ToString()] = currentWorksheet.Cells[rowNumber, i].Value.ToString();
}
else
dr[currentWorksheet.Cells[1, i].Value.ToString()] = "";
}

dt.Rows.Add(dr);
}
...
}
}
}
}
Comments: Test that the file exists on the server and that you have the approriate permissions to read it.

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>