1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
Excel.Application eApplication = null;
Excel.Workbook eWorkBook = null;
Excel.Sheets eSheets = null;
Excel.Worksheet eWorkSheet = null;
Excel.Range srcRange = null;
Excel.Range dstRange = null;
 
string AppPath = Application.StartupPath;   //Project path
 
eApplication = new Excel.Application();     //Execute Excel
eApplication.Visible = false;
eWorkBook = eApplication.Workbooks.Open(AppPath + @"\jhhyun_test.xls");
eSheets = eWorkBook.Sheets;
eWorkSheet = eSheets["Sheet1"as Excel.Worksheet;
 
/*Excel to PDF*/
 
object paramMissing = Type.Missing;
string paramExportFilePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) 
                                + @"\1_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"+ ".pdf";
Excel.XlFixedFormatType paramExportFormat = Excel.XlFixedFormatType.xlTypePDF;
Excel.XlFixedFormatQuality paramExportQuality = Excel.XlFixedFormatQuality.xlQualityStandard;
bool paramOpenAfterPublish = false;
bool paramIncludeDocProps = true;
bool paramIgnorePrintAreas = true;
object paramFromPage = Type.Missing;
object paramToPage = Type.Missing;
 
eWorkBook.ExportAsFixedFormat(paramExportFormat,
            paramExportFilePath, paramExportQuality,
            paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
            paramToPage, paramOpenAfterPublish,
            paramMissing);
eWorkBook.Close(false);
eWorkBook = null;
 
eApplication.Quit();
eApplication = null;
cs