I have an immediate requirement where I need to open some specific excel sheets from an existing Excel file which resides on a system. I want to know how this can be accomplished using Classic ASP . I tried searching on the internet but couldn't find anything specific. Need some suggestions...:)
I hope this makes sense
I tried below code but all in vain.
<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>
For example, how you can show your Excel file into a webbrowser, a simple example in C#. Are you planning to write it in pure ASP, or in 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);
}
}
This can be found under: http://bytes.com/topic/c-sharp/answers/477965-excel-files-html-using-c
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.