2

I have been looking for a solution all over the last days and I found that this library EPPlus allows retrieving in the same time formatting besides the actual data, plus charts, if needed, from Excel files which is what I am aiming at the moment.

Could you please explain to me step by step how to read a Range of cells from an Excel (like A1:P34) file that resides at a certain path, via ASP.NET/C#?

PATH would be something like //ServerName/Folder1/Folder2/Folder3/ExcelFileName.xlsx

I looked over the web, but there is not explicit documentation for my level of C# expertise on this. I tried several examples but none displayed the Excel Range into the webpage. (e.g this one.)

Note: the three examples I have tried all included an File Upload Control, I do not need such. I want to read the Excel file from a specified location over the local network.

EPPlus library is available here.

If you can recommend me any simpler resources to understand EPPlus on:
-reading from Excel
-writing from Excel
-reading charts from Excel

This EPPlus does seem wonderful in its functionality.

pnuts
  • 58,317
  • 11
  • 87
  • 139
George
  • 653
  • 6
  • 18

1 Answers1

2

To read a file off the server take a look at this:

Open ExcelPackage Object with Excel application without saving it on local file path

Just need to set the var path part for your file.

To actually put the excel data on a web page, that is not so easy. See this:

Generating a HTML table from an Excel file using EPPlus?

Response to Comment:

Hosting an actual excel sheet in web page is temperamental at best but there are ways to do it (I haven't tried it personally). SharePoint is probably your best option if you have it available. If not, you would have to use an iFrame or some kind of office web component. Check this out:

how to display excel sheet in html page

Community
  • 1
  • 1
Ernie S
  • 13,902
  • 4
  • 52
  • 79
  • Thank you. But I am not sure, second link says something about a basic HTML table. My aim is to hold the formatting of the cells from the original Excel source, its Conditional Formatting rules. Is there some other possibility? What about including Charts from the same Excel file into the webpage? – George Oct 09 '15 at 18:57
  • By the way, I tried the Interop approach, but it seems it does not work for web applications(servers). Just correct me if i am wrong. So far, I know how to include the data into the webform via Microsoft Ace OLEDB provider, I have found a workaround to fulfill the conditional formatting by using some new CSS3 properties . But, there is an issue I am not able to resolve yet. there some cells which are formatted in Excel as Percentages, I can not translate them but numbers with decimals.Right, there is the possiblility of multiplying with 100 , but still, no "percentage" sign appears. – George Oct 09 '15 at 19:02
  • therefore, best if i learned EPPlus which seems like a Swiss-knife. – George Oct 09 '15 at 19:03