OK worked it out.
// Save Excel Docmnet as HTML
string excelFile = "@"C:\excelDocument.xls";
Excel.Application excelApp = new Excel.ApplicationClass();
Excel.Workbook excelWorkbook =
excelApp.Workbooks._Open(excelFile, false, false, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);
Excel.Sheets excelSheet = excelWorkbook.Worksheets;
object sheetFormat =
Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml ;
String outputFile = @"C:\excelDocument.xls";
Microsoft.Office.Interop.Excel.Worksheet excelCurrentSheet =
(Microsoft.Office.Interop.Excel.Worksheet)excelShe et.get_Item(Convert.ToInt32(SheetNametextBox.Text) );
excelCurrentSheet.SaveAs(outputFile, sheetFormat, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
excelSheet = null;
excelCurrentSheet = null;
excelWorkbook = null;
excelApp.ActiveWorkbook.Close(false, excelFile, false);
if (excelApp != null)
{
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject(excelApp);
}
excelApp = null;
//////////////////////////// Read and collect html markup value from sheet
you need
WebRequest webRequest =
WebRequest.Create(@"C:\Inetpub\wwwroot\WebSites\sh eet057.htm");
StreamReader streamRequest = new
StreamReader(webRequest.GetResponse().GetResponseS tream());
System.Text.StringBuilder stringBuilderRequest = new
System.Text.StringBuilder();
string stringLine = "";
while ((stringLine = streamRequest.ReadLine()) != null)
{
if (stringLine.Length 0)
stringBuilderRequest.Append(stringLine);
}
streamRequest.Close();
pageValue = stringBuilderRequest.ToString();
CreateASCX();
////////////////////////////////// Create new page
private void CreateASCX()
{
// strip out reference to home page and tab page
int findStart = pageValue.IndexOf("</style>");
findStart = findStart + 8;
int findEnd = pageValue.IndexOf("</script>");
findEnd = findEnd - findStart;
pageValue = pageValue.Remove(findStart, findEnd);
StreamWriter SW;
SW = File.CreateText(@"C:\Inetpub\wwwroot\WebSites\newP age.ascx");
SW.WriteLine(pageValue.ToString());
SW.Close();
Application.Exit();
}
"BrianDH" wrote:
I have been given the task, to take an excel document with over 50 sheets and
is updated weekly, and pull from it 5 of those sheets, convert them to html
so they can be viewed on our company web site.
Does anyone know of a way to pull a single sheet out of a workbook, convert
it to a stand alone html document?
I can do the complete document, but the sheets and are back related to the
main document and I can find no way via code to seperate them and make them
stand alone html documents.
Thanks
Brian