简体   繁体   English

如何从Excel文件中检索数据

[英]How retrieve data from an Excel file

How can we get a specific value from an Excel file if we don't have a header row in the file? 如果文件中没有标题行,如何从Excel文件中获取特定值? In my Excel file the first two lines are empty. 在我的Excel文件中,前两行为空。 I need the value at Row 10 , Column F . 我需要Row 10 Column F的值。

If you really are doing this in Javascript then maybe this will be what you need. 如果您确实使用Javascript进行此操作,那么也许这将是您所需要的。

var excel=new ActiveXObject("Excel.Application");
var book=excel.Workbooks.Open("C:\my.xls");
var sheet=book.Sheets.Item(1);
var value=sheet.Range("F10");

It's ActiveX though so this will only work in Internet Explorer. 虽然是ActiveX,所以只能在Internet Explorer中使用。 I got this code from http://social.msdn.microsoft.com/Forums/en/sidebargadfetdevelopment/thread/783724f0-526d-4c1d-a565-ebcdbca83cb8 我从http://social.msdn.microsoft.com/Forums/en/sidebargadfetdevelopment/thread/783724f0-526d-4c1d-a565-ebcdbca83cb8获得了此代码

If you want to access an Excel-file from the server, you should use a suitable Excel-library. 如果要从服务器访问Excel文件,则应使用合适的Excel库。 For example, use EPPlus in ASP.NET. 例如,在ASP.NET中使用EPPlus

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM