[英]How can I write a greeting in classic ASP using a mixture of HTML and ASP
[英]How can i open an existing Excel file using the classic asp
我有一個緊急要求,我需要從駐留在系統上的現有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>
例如,如何將Excel文件顯示到Web瀏覽器中,這是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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.