public Worksheet DoExport(RevisionAct act)
        {
            _worksheet = new Worksheet("Акт сверки");
            _worksheet.Cells.ColumnWidth[0] = (ushort)2.5 * 256;
            _worksheet.Cells.ColumnWidth[1] = (ushort)23 * 256;
            _worksheet.Cells.ColumnWidth[2] = (ushort)7 * 256;
            _worksheet.Cells.ColumnWidth[3] = (ushort)7 * 256;
            _worksheet.Cells.ColumnWidth[4] = (ushort)2.5 * 256;
            _worksheet.Cells.ColumnWidth[5] = (ushort)23 * 256;
            _worksheet.Cells.ColumnWidth[6] = (ushort)7 * 256;
            _worksheet.Cells.ColumnWidth[7] = (ushort)7 * 256;
            var h1 = new CellStyle {
                Font = new Font("Arial", 11)
                {
                    Bold = true
                },
                HorizontalAlignment = HorizontalAlignment.Center
            };
            var h2 = new CellStyle {
                Font = new Font("Arial", 10)
                {
                    Bold = true,
                },
                Warp = true,
            };

            var mark = new CellStyle {
                HorizontalAlignment = HorizontalAlignment.Center,
                Warp = true,
            };

            var longWord = new CellStyle {
                Warp = true
            };

            var underScrore = new CellStyle {
                Borders = new Borders {
                    Bottom = BorderStyle.Thin
                }
            };

            var table = new CellStyle {
                Font    = new Font("Arial", 8),
                Borders = Borders.Box(BorderStyle.Thin),
            };

            Row(h1, "Акт сверки", new Merge(8));
            var row = Row(mark,
                          String.Format("взаимных расчетов по состоянию на {0} между {1} и {2} по договору № {3}",
                                        act.EndDate.ToShortDateString(),
                                        act.Payer.Recipient.FullName,
                                        act.Payer.JuridicalName,
                                        act.Payer.Id),
                          new Merge(8));

            row.Height = 1440 / 72 * 43;
            row        = Row(longWord,
                             String.Format("Мы, нижеподписавшиеся, __________________ {0} _________________________,"
                                           + "с одной стороны, и ________________________ {1} __________________________, "
                                           + "с другой стороны составили настоящий акт сверки в том, что состояние взаимных расчетов по данным учета следующее:",
                                           act.Payer.Recipient.FullName,
                                           act.Payer.JuridicalName),
                             new Merge(8));
            row.Height = 1440 / 72 * 62;
            Row(table,
                String.Format("По данным {0}, руб.", act.Payer.Recipient.FullName), new Merge(4),
                String.Format("По данным {0}, руб.", act.Payer.JuridicalName), new Merge(4));
            Row(table,
                "№ п/п", "Наименование операции, документы", "Дебет", "Кредит",
                "№ п/п", "Наименование операции, документы", "Дебет", "Кредит");
            var index = 1;

            foreach (var move in act.Movements)
            {
                Row(table,
                    index, move.Name, move.Debit.ToString("#.#"), move.Credit.ToString("#.#"),
                    "", "", "", "");
                index++;
            }
            Skip();
            Row(String.Format("По данным {0}", act.Payer.Recipient.FullName), new Merge(4));
            row        = Row(h2, act.Result, new Merge(4));
            row.Height = 1440 / 72 * 29;
            Skip();
            Row(String.Format("От {0}", act.Payer.Recipient.FullName), new Merge(4),
                String.Format("От {0}", act.Payer.JuridicalName), new Merge(4));
            Skip(2);
            Row("", underScrore, "", underScrore, String.Format("({0})", act.Payer.Recipient.Boss), "",
                "", underScrore, "", underScrore, "", "");
            Skip();
            Row("М.П.", "", "", "",
                "М.П.", "", "", "");
            _worksheet.Cells[0, 0] = new Cell("Акт сверки")
            {
                Style = h1
            };
            return(_worksheet);
        }
Beispiel #2
0
        public void WriteReportToFile(DataSet data, string file, BaseReportSettings settings)
        {
            var workbook = new Workbook();

            foreach (var row in data.Tables["prices"].Rows.Cast <DataRow>())
            {
                var offers = data.Tables[row["PriceCode"].ToString()];
                if (offers == null)
                {
                    continue;
                }

                var name = row["ShortName"] + " " + row["PriceName"];
                if (name.Length > 26)
                {
                    name = name.Substring(0, 26);
                }

                var header = new CellStyle {
                    Warp = true,
                    Font = new Font("Arial", 11)
                    {
                        Bold = true
                    },
                    HorizontalAlignment = HorizontalAlignment.Center
                };

                var body = new CellStyle {
                    Borders = Borders.Box(BorderStyle.Thin)
                };

                var sheet = new Worksheet(name);

                sheet.Cells[0, 0] = new Cell("Код")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[0] = 11 * 255;
                sheet.Cells[0, 1]          = new Cell("Код изготовителя")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[1] = 11 * 255;
                sheet.Cells[0, 2]          = new Cell("Наименование")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[2] = 30 * 255;
                sheet.Cells[0, 3]          = new Cell("Изготовитель")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[3] = 25 * 255;
                sheet.Cells[0, 4]          = new Cell("Цена")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[4] = (ushort)(15.5 * 255);
                sheet.Cells[0, 5]          = new Cell("Остаток")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[5] = 17 * 255;
                sheet.Cells[0, 6]          = new Cell("Срок годности")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[6] = 10 * 255;
                sheet.Cells[0, 7]          = new Cell("Примечание")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[7] = 20 * 255;
                sheet.Cells[0, 8]          = new Cell("ЖНВЛС")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[0] = 11 * 255;
                sheet.Cells[0, 9]          = new Cell("Лек. ассортимент")
                {
                    Style = header
                };
                sheet.Cells.ColumnWidth[0] = 15 * 255;

                var i = 1;
                foreach (var offer in offers.Rows.Cast <DataRow>())
                {
                    sheet.Cells[i, 0] = new Cell(offer["Code"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 1] = new Cell(offer["CodeCr"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 2] = new Cell(offer["Product"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 3] = new Cell(offer["Producer"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 4] = new Cell(offer["Cost"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 5] = new Cell(offer["Quantity"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 6] = new Cell(offer["Period"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 7] = new Cell(offer["Note"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 8] = new Cell(offer["VitallyImportant"])
                    {
                        Style = body
                    };
                    sheet.Cells[i, 9] = new Cell(offer["Pharmacie"])
                    {
                        Style = body
                    };
                    i++;
                }


                workbook.Worksheets.Add(sheet);
            }
            workbook.Save(file);
        }