I'm trying to read and excel file from the client using EPPlus without uploading it to the server or using a file upload control. The file will be located in the same location all the time.
我正在尝试使用EPPlus从客户端读取和优化文件,而无需将其上传到服务器或使用文件上传控件。该文件将始终位于同一位置。
Is this possible? When looking it to it, I only found solutions which read from the server or this one which uses a file upload control which I do not want.
这可能吗?在查看它时,我只找到了从服务器读取的解决方案或使用我不想要的文件上传控制的解决方案。
If it is not possible using EPPlus, what other method would you suggest to read an excel file in ASP.net C# from a client location (network drive available to all users) without sending it to the server and using the file upload control.
如果无法使用EPPlus,您建议从客户端位置(所有用户可用的网络驱动器)读取ASP.net C#中的excel文件,而不将其发送到服务器并使用文件上载控件。
Thanks for the help!
谢谢您的帮助!
EDIT: So iv added this active x script on my aspx page:
编辑:所以我在我的aspx页面上添加了这个活动的x脚本:
<script type="text/javascript">
var readExcel = function() {
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("C:\\Users\\qt98512\\Desktop\\Book1.xlsx");
var excel_sheet = excel_file.Worksheets("Sheet1");
var data = excel_sheet.Cells(1, 1).Value;
var data2 = excel_sheet.Cells(0, 0).Value;
return data;
}
</script>
Assuming that is correct, how do I access the returned data in my c# page? I have a button running the script like this:
假设这是正确的,我如何在我的c#页面中访问返回的数据?我有一个运行脚本的按钮,如下所示:
protected void testbuttonExcel_Click(object sender, EventArgs e)
{
string text = ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "script", "readExcel();", true);
}
1 个解决方案
#1
0
In most of the case, you have to upload the file into server in order to really use it. However, if you only need to use the file for once, you may consider to put the file into memory and stream your file.
在大多数情况下,您必须将文件上传到服务器才能真正使用它。但是,如果您只需要使用该文件一次,则可以考虑将文件放入内存并流式传输文件。
This show how to store the file data to memory
这显示了如何将文件数据存储到内存中
This case are using excel with EPP too. Check if it suit your needs
这个案例也使用excel与EPP。检查它是否符合您的需求
#1
0
In most of the case, you have to upload the file into server in order to really use it. However, if you only need to use the file for once, you may consider to put the file into memory and stream your file.
在大多数情况下,您必须将文件上传到服务器才能真正使用它。但是,如果您只需要使用该文件一次,则可以考虑将文件放入内存并流式传输文件。
This show how to store the file data to memory
这显示了如何将文件数据存储到内存中
This case are using excel with EPP too. Check if it suit your needs
这个案例也使用excel与EPP。检查它是否符合您的需求