-
April 5th, 2013, 04:34 AM
#1
Excel save as html/pdf problem
I have an Excel workbook with several sheets.
I save it as Excel with everything in it, and that is fine.
However, when I export to HTML and PDF, I want the html/pdf file to contain only some of the sheets (which I choose).
How to do that?
My current code:
Code:
if (excel)
{
if (!System.IO.Directory.Exists(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieExcel"].ToString(), path)))
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieExcel"].ToString(),path));
tmp = System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieExcel"].ToString(),path, lokation + ".xls");
files.Add(tmp);
xlWorkBook.SaveAs(tmp, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
}
if (html)
{
if (!System.IO.Directory.Exists(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieHtml"].ToString(), path)))
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieHtml"].ToString(), path));
tmp = System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsserieHtml"].ToString(), path, lokation + ".html");
files.Add(tmp);
xlWorkBook.SaveAs(tmp, Excel.XlFileFormat.xlHtml, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
}
if (pdf)
{
if (!System.IO.Directory.Exists(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsseriePdf"].ToString(), path)))
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsseriePdf"].ToString(), path));
xlWorkBook.Worksheets.Select();
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;
tmp = System.IO.Path.Combine(ConfigurationManager.AppSettings["TidsseriePdf"].ToString(), path, lokation + ".pdf");
files.Add(tmp);
XlFixedFormatQuality paramExportQuality =
XlFixedFormatQuality.xlQualityStandard;
bool paramOpenAfterPublish = false;
bool paramIncludeDocProps = true;
bool paramIgnorePrintAreas = true;
object paramFromPage = Type.Missing;
object paramToPage = Type.Missing;
object paramMissing = Type.Missing;
if (xlWorkBook != null)
xlWorkBook.ExportAsFixedFormat(paramExportFormat,
tmp, paramExportQuality,
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
paramToPage, paramOpenAfterPublish,
paramMissing);
}
Thanks in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|