Пример #1
0
        static void Main(string[] args)
        {
            // Create a workbook to preview.
            IWorkbook  workbook  = Factory.GetWorkbook();
            IWorksheet worksheet = workbook.Worksheets[0];

            worksheet.Name = "MySheet";
            worksheet.Cells["A1:J100"].Formula = "=ROUND(RAND()*ROW()*COLUMN(),0)";
            // Set the print area.
            IPageSetup pageSetup = worksheet.PageSetup;

            pageSetup.PrintArea = "A1:J100";
            // This will force the workbook to be printed on one page.
            pageSetup.FitToPagesTall = 1;
            pageSetup.FitToPagesWide = 1;
            // Create a WorkbookView and display the workbook in Print Preview.
            var workbookView = new SpreadsheetGear.Windows.Forms.WorkbookView(workbook);

            workbookView.PrintPreview();
        }
Пример #2
0
        public static void Main(string[] Pages)
        {
            XmlReader reader = XmlReader.Create(Pages[0]);
            DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary <string, string>));

            Dictionary <string, string> list = (Dictionary <string, string>)serializer.ReadObject(reader);

            reader.Close();

            SpreadsheetGear.Windows.Forms.WorkbookView WV = new SpreadsheetGear.Windows.Forms.WorkbookView();

            FeuerwehrCloud.Helper.Logger.WriteLine("|  > [ExcelPrinter] *** Opening " + Pages[1]);
            WV.ActiveWorkbook = SpreadsheetGear.Factory.GetWorkbookSet().Workbooks.Open(Pages[1]);
            WV.GetLock();
            SpreadsheetGear.IWorksheet WB = WV.ActiveWorkbook.Worksheets [0];
            for (int x = 0; x < 25; x++)
            {
                for (int y = 0; y < 25; y++)
                {
                    SpreadsheetGear.IRange IR = WB.Cells [x, y];
                    string CValue             = IR.Text;
                    try {
                        if (CValue == "#EINSATZORT#")
                        {
                            IR.Value = list["EinsatzOrt"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (CValue == "#EINSATZNR#")
                        {
                            IR.Value = list["EinsatzNr"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (CValue == "#EINSATZSTRASSE#")
                        {
                            IR.Value = list["EinsatzStrasse"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (CValue == "#EINSATZABSCHNITT#")
                        {
                            IR.Value = list["EinsatzAbschnitt"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZKREUZUNG#")
                        {
                            IR.Value = list["EinsatzKreuzung"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZOBJEKT#")
                        {
                            IR.Value = list["EinsatzObjekt"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZBMERKUNG#")
                        {
                            IR.Value = list["EinsatzBemerkung"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZPRIORITAET#")
                        {
                            IR.Value = list["EinsatzPrioritaet"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZSTICHWORT#")
                        {
                            IR.Value = list["EinsatzStichwort"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#EINSATZSCHLAGWORT#")
                        {
                            IR.Value = list["EinsatzSchlagwort"];
                        }
                    } catch (Exception e1) {
                    }
                    try {
                        if (IR.Value == "#DATUM#")
                        {
                            IR.Value = System.DateTime.Now.ToString("d");
                        }
                    } catch (Exception e1) {
                    }
                }
            }
            WB.PageSetup.LeftMargin     = 0;
            WB.PageSetup.RightMargin    = 0;
            WB.PageSetup.TopMargin      = 0;
            WB.PageSetup.BottomMargin   = 0;
            WB.PageSetup.PaperSize      = SpreadsheetGear.PaperSize.A4;
            WB.PageSetup.FitToPagesWide = 1;
            WV.ReleaseLock();
            WV.Print(false);
            WV.GetLock();
            WV.ActiveWorkbook.Close();
        }