我正在从 excelsheet 读取值,一切正常,但是当我在服务器上发布时,它不再起作用。问题是我正在使用 microsoft.interop 而我的服务器不支持它。我认为解决方案是使用 Document.Format.OpenXml,我已经包含了参考,但我没有以正确的方式更改我的代码。有人能帮我吗?
我的代码:
public class ScoreCalculator
{
//private static DocumentFormat.OpenXml.Extensions.WorksheetReader appExcell;
private static Microsoft.Office.Interop.Excel.Application appExcel;
private static Workbook newWorkbook = null;
private static Worksheet objsheet = null;
//Method to initialize opening Excel
public void excel_init(String path)
{
appExcel = new DocumentFormat.OpenXml.Extensions.WorksheetReader;
newWorkbook = appExcel.Workbooks.Open(path, true, true);
objsheet = (Worksheet)appExcel.ActiveWorkbook.ActiveSheet;
}