Beispiel #1
0
        public void LoadReport(string fileName, bool autoFit)
        {
            Workbook book = new Workbook();


            book.LoadFromFile(fileName);

            ReportBookTemplate tplbook = new ReportBookTemplate();

            tplbook.LoadTemplate(db, book, paramMap);
            tplbook.FillTemplate();

            List <ReportSheetTemplate> tplList = tplbook.sheetList;

            // tpl.Clear();

            // Open with Excel

/*			xlapp.Visible = false;*/

            try
            {
                ClearReport(autoFit, book, tplList);
                // xlapp.Workbooks.Close ();

                // Copy Image
            }
            finally
            {
                book.Save();
                book.Dispose();

/*				xlapp.DisplayAlerts = true ;
 *
 *                              xlapp.Visible = true;
 */
                RemoveWarning(fileName);

                Process.Start(fileName);
            }


            // remove warnning sheet.
        }
Beispiel #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            _PrintExcel.Workbook workbook = new _PrintExcel.Workbook();
            workbook.LoadFromFile(filename);

            _PrintExcel.Worksheet sheet = workbook.Worksheets["printout"];
            sheet.SaveToPdf(path + "Sizing Printout.pdf");
            System.Diagnostics.Process.Start("explorer.exe", path + "Sizing Printout.pdf");
            workbook.Dispose();



            //PrintDialog dialog = new PrintDialog();
            //dialog.AllowPrintToFile = true;
            //dialog.AllowCurrentPage = true;
            //dialog.AllowSomePages = true;
            //dialog.AllowSelection = true;
            //dialog.UseEXDialog = true;
            //dialog.PrinterSettings.Duplex = Duplex.Simplex;
            //dialog.PrinterSettings.PrintRange = PrintRange.SomePages;
            //workbook.PrintDialog = dialog;
            //PrintDocument pd = workbook.PrintDocument;
            //if (dialog.ShowDialog() == DialogResult.OK)
            //{ pd.Print(); }

            //Application excel = new Application();


            //_Excel.Workbook workbook = excel.Workbooks.Open(filename, ReadOnly: false, Editable: true);
            //_Excel.Worksheet worksheet = workbook.Worksheets["printout"] as _Excel.Worksheet;



            //worksheet.PrintPreview();
            //worksheet.PrintOut(From:1,To:2,Copies:1, Preview:true, Type.Missing, PrintToFile:true, Type.Missing, Type.Missing);
            //worksheet.PrintPreview();
            //PrintDialog printDlg = new PrintDialog();

            /*PrintDocument printDoc = new PrintDocument();
             * printDoc.DocumentName = "Print Document";
             * printDlg.Document = printDoc;
             * printDlg.AllowSelection = true;
             * printDlg.AllowSomePages = true;
             * if (printDlg.ShowDialog() == DialogResult.OK) printDoc.Print();*/
            //    worksheet.PrintOut(
            //1, 1, 1, Type.Missing,
            //Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            //    // Cleanup:
            //    GC.Collect();
            //    GC.WaitForPendingFinalizers();

            //    Marshal.FinalReleaseComObject(worksheet);

            //    workbook.Close(false, Type.Missing, Type.Missing);
            //    Marshal.FinalReleaseComObject(workbook);

            //    excel.Quit();
            //    Marshal.FinalReleaseComObject(excel);

            /*workbook.DisplayAlerts = false;
             * excel.ActiveWorkbook.Save();
             * excel.Application.Quit();
             * excel.Quit();*/
        }