1

我有一个即时需求,我需要从系统上的现有 Excel 文件中打开一些特定的 Excel 工作表。我想知道如何使用Classic ASP来实现这一点。我尝试在互联网上搜索,但找不到任何具体内容。需要一些建议...:)

我希望这是有道理的

我尝试了下面的代码,但都是徒劳的。

<html> 
<body bgcolor="white" text="black"> 

        <%Dim xlObject, xlBook,wks Set xlObject = CreateObject("Excel.Application") xlObject.visible = False 
        Set xlBook = xlObject.Workbooks.open("C:\\Users\\Administrator\\Desktop\\Final Help file 11june13.xls") 
        Set wks = xlObject.ActiveWorkBook.Worksheets(1) 
        response.Write("permbajtja e qelizes eshte: "&wks.Cells(3,1)) 
        xlBook.Close xlObject.Quit 
        Set wks = Nothing 
        Set xlBook = Nothing 
        Set xlObject = Nothing %> 
    </form>
</body> 
</html>
4

1 回答 1

-3

例如,如何将 Excel 文件显示到网络浏览器中,这是 C# 中的一个简单示例。您打算用纯 ASP 还是 ASP.NET 编写它?

public static void ConvertExcelFile(String excelFile)
{
        Microsoft.Office.Interop.Excel.Application excel = null;
        Microsoft.Office.Interop.Excel.Workbook xls = null;
        try
        {
            excel = new Microsoft.Office.Interop.Excel.Application();
            object missing = Type.Missing;
            object trueObject = true;
            excel.Visible = false;
            excel.DisplayAlerts = false;
            xls = excel.Workbooks.Open(excelFile, missing, trueObject, missing,

                    missing, missing, missing, missing, missing, missing, missing, missing,

                    missing, missing, missing);
            object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
            IEnumerator wsEnumerator=excel.ActiveWorkbook.Worksheets.GetEnumerator();
            int i = 1;
            while (wsEnumerator.MoveNext())
            {
                Microsoft.Office.Interop.Excel.Worksheet wsCurrent =
                (Microsoft.Office.Interop.Excel.Worksheet)wsEnumerator.Current;
                String outputFile =excelFile + "." + i.ToString() + ".html";
                wsCurrent.SaveAs(outputFile, format, missing, missing, missing,
                missing, missing, missing, missing, missing);
                ++i;
            }
            excel.Quit();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error accessing Excel document.\n\n" +
            ex.Message);
        }
    }

这可以在以下位置找到: http: //bytes.com/topic/c-sharp/answers/477965-excel-files-html-using-c

于 2013-06-12T12:17:24.223 回答