public void ExportSelfInvoice(SelfInvoiceDataObject selfInvoice) { var sheet = CreateSelfInvoiceSheet(string.Join("autofatt.", selfInvoice.InvoiceNumber)); var row = sheet.CreateRow(4); row.HeightInPoints = 18f; var cell = row.CreateCell(3); //cellStyle.BorderBottom = CellBorderType.THIN; cell.SetCellValue("Autofattura"); cell.CellStyle = CellStyle("ITC Zapf Chancery", 14); CreateInvoiceHeaderSquare(sheet, selfInvoice); CreateBody(sheet, selfInvoice); }
private void CreateInvoiceHeaderSquare(Sheet sheet, SelfInvoiceDataObject selfInvoice) { var row = sheet.CreateRow(5); var cell = row.CreateCell(0); cell.SetCellValue("Cliente"); cell.CellStyle = CellStyle(bold: true, alignment: HorizontalAlignment.CENTER); // ROW 6 row = sheet.CreateRow(6); cell = row.CreateCell(0); cell.SetCellValue("Nome:O.S. Trading S.r.l Soc. Unipersonale"); cell.CellStyle = CellStyle(cellBorders: new[] { "top", "left" }); cell.RichStringCellValue.ApplyFont(5, 41, GetBoldFont()); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "top", "right" }); cell = row.CreateCell(3); cell.SetCellValue("Data ft."); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "left" }); cell = row.CreateCell(4); cell.SetCellValue(selfInvoice.InvoiceDate.ToString("dd/MM/yyyy")); cell.CellStyle = CellStyle(cellBorders: new[] { "top", "right" }, alignment: HorizontalAlignment.RIGHT); // ROW 7 row = sheet.CreateRow(7); cell = row.CreateCell(0); cell.SetCellValue("Indirizzo:Via Mascagni snc"); cell.CellStyle = CellStyle(cellBorders: new[] { "left" }); cell.RichStringCellValue.ApplyFont(10, 26, GetBoldFont()); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }); cell = row.CreateCell(3); cell.CellStyle = CellStyle(cellBorders: new[] { "left" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }); // ROW 8 row = sheet.CreateRow(8); cell = row.CreateCell(0); cell.SetCellValue("Cap. Città:20040 Usmate Velate"); cell.CellStyle = CellStyle(cellBorders: new[] { "left" }); cell.RichStringCellValue.ApplyFont(11, 30, GetBoldFont()); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }); cell = row.CreateCell(3); cell.CellStyle = CellStyle(cellBorders: new[] { "left" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }); // ROW 9 row = sheet.CreateRow(9); cell = row.CreateCell(0); cell.SetCellValue("C.F: 05962770961"); cell.CellStyle = CellStyle(cellBorders: new[] { "left" }); cell.RichStringCellValue.ApplyFont(4, 17, GetBoldFont()); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }); cell = row.CreateCell(3); cell.SetCellValue("Numero ft"); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "left" }); cell = row.CreateCell(4); cell.SetCellValue(string.Format("{0}/{1}", selfInvoice.InvoiceNumber.ToString(CultureInfo.InvariantCulture), selfInvoice.InvoiceYear.ToString(CultureInfo.InvariantCulture).Substring(2))); cell.CellStyle = CellStyle(cellBorders: new[] { "right" }, alignment: HorizontalAlignment.RIGHT); // ROW 10 row = sheet.CreateRow(10); cell = row.CreateCell(0); cell.SetCellValue("P.Iva:05962770961"); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left" }); cell.RichStringCellValue.ApplyFont(6, 17, GetBoldFont()); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "right" }); cell = row.CreateCell(3); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "right" }); }
private void CreateBody(Sheet sheet, SelfInvoiceDataObject selfInvoice) { // ROW 12 var row = sheet.CreateRow(12); var cell = row.CreateCell(0); cell.SetCellValue("Descrizione"); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "bottom", "left", "right" }, alignment: HorizontalAlignment.CENTER); cell = row.CreateCell(1); cell.SetCellValue("Quantità ton."); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "bottom", "left", "right" }, alignment: HorizontalAlignment.CENTER); cell = row.CreateCell(2); cell.SetCellValue("Prezzo"); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "bottom", "left", "right" }, alignment: HorizontalAlignment.CENTER); cell = row.CreateCell(3); cell.SetCellValue("IVA"); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "bottom", "left", "right" }, alignment: HorizontalAlignment.CENTER); cell = row.CreateCell(4); cell.SetCellValue("Importo in € "); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "top", "bottom", "left", "right" }, alignment: HorizontalAlignment.CENTER); AddBodyEmptyRow(sheet, 13); AddBodyEmptyRow(sheet, 14); AddBodyEmptyRow(sheet, 15); AddBodyEmptyRow(sheet, 16); // ROW 17 row = sheet.CreateRow(17); cell = row.CreateCell(0); cell.SetCellValue(selfInvoice.Material.Name); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); cell = row.CreateCell(1); cell.SetCellValue((double)selfInvoice.Quantity); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }, alignment: HorizontalAlignment.RIGHT); cell = row.CreateCell(2); cell.SetCellValue("€ " + selfInvoice.Material.Price.ToString("N2")); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }, alignment: HorizontalAlignment.RIGHT); cell = row.CreateCell(3); //cell.SetCellValue(""); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }, alignment: HorizontalAlignment.RIGHT); cell = row.CreateCell(4); cell.SetCellValue("€ " + (selfInvoice.Quantity * selfInvoice.Material.Price).ToString("N2")); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }, alignment: HorizontalAlignment.RIGHT); AddBodyEmptyRow(sheet, 18); AddBodyEmptyRow(sheet, 19); AddBodyEmptyRow(sheet, 20); AddBodyEmptyRow(sheet, 21); AddBodyEmptyRow(sheet, 22); AddBodyEmptyRow(sheet, 23); AddBodyEmptyRow(sheet, 24); AddBodyEmptyRow(sheet, 25); AddBodyEmptyRow(sheet, 26); AddBodyEmptyRow(sheet, 27); AddBodyEmptyRow(sheet, 28); AddBodyEmptyRow(sheet, 29); AddBodyEmptyRow(sheet, 30); AddBodyEmptyRow(sheet, 31); AddBodyEmptyRow(sheet, 32); AddBodyEmptyRow(sheet, 33); AddBodyEmptyRow(sheet, 34); AddBodyEmptyRow(sheet, 35); AddBodyEmptyRow(sheet, 36); AddBodyEmptyRow(sheet, 37); AddBodyEmptyRow(sheet, 38); AddBodyEmptyRow(sheet, 39); AddBodyEmptyRow(sheet, 40); row = sheet.CreateRow(41); cell = row.CreateCell(0); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); cell = row.CreateCell(1); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); cell = row.CreateCell(2); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); cell = row.CreateCell(3); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); row = sheet.CreateRow(42); cell = row.CreateCell(2); cell.SetCellValue("Imponibile"); cell = row.CreateCell(4); cell.SetCellValue("€ " + (selfInvoice.Quantity * selfInvoice.Material.Price).ToString("N2")); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }, alignment: HorizontalAlignment.RIGHT); row = sheet.CreateRow(43); cell = row.CreateCell(0); cell.SetCellValue("Modalità di pagamento "); cell = row.CreateCell(1); cell.SetCellValue("Pag 1"); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); row = sheet.CreateRow(44); cell = row.CreateCell(2); cell.SetCellValue("Iva"); cell = row.CreateCell(4); cell.SetCellValue("esente art. 74"); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); row = sheet.CreateRow(45); cell = row.CreateCell(0); cell.CellStyle = CellStyle(cellBorders: new[] { "top", "left", "right" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); row = sheet.CreateRow(46); cell = row.CreateCell(0); cell.SetCellValue("Rimessa diretta per contanti"); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); cell = row.CreateCell(4); cell.CellStyle = CellStyle(cellBorders: new[] { "left", "right" }); row = sheet.CreateRow(47); cell = row.CreateCell(0); cell.CellStyle = CellStyle(cellBorders: new[] { "bottom", "left", "right" }); cell = row.CreateCell(2); cell.SetCellValue("TOTALE"); cell = row.CreateCell(4); cell.SetCellValue("€ " + (selfInvoice.Quantity * selfInvoice.Material.Price).ToString("N2")); cell.CellStyle = CellStyle(bold: true, cellBorders: new[] { "bottom", "left", "right" }, alignment: HorizontalAlignment.RIGHT); }