Ergebnisse werden Exportiert in Excel
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
using Syncfusion.XlsIO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Schnittstelle.Export
|
||||
@@ -18,20 +20,107 @@ namespace Schnittstelle.Export
|
||||
|
||||
application.DefaultVersion = ExcelVersion.Xlsx;
|
||||
IWorkbook workbook = application.Workbooks.Create(KanalObjekte.Count);
|
||||
IStyle CellStyle = workbook.Styles.Add("HeaderStyle");
|
||||
|
||||
CellStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
|
||||
CellStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
|
||||
CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
|
||||
CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
|
||||
for (int i = 0; i < KanalObjekte.Count; i++)
|
||||
{
|
||||
IWorksheet worksheet = workbook.Worksheets[i];
|
||||
KanalObjekt k = KanalObjekte[i];
|
||||
CalculateHaltung(k, worksheet);
|
||||
CalculateHaltung(k, worksheet, CellStyle);
|
||||
}
|
||||
FileStream stream = new FileStream("beurteilung.xlsx", FileMode.Create, FileAccess.ReadWrite);
|
||||
workbook.SaveAs(stream);
|
||||
stream.Dispose();
|
||||
}
|
||||
|
||||
private static void CalculateHaltung(KanalObjekt haltung, IWorksheet worksheet)
|
||||
private static void CalculateHaltung(KanalObjekt haltung, IWorksheet worksheet, IStyle cellStyle)
|
||||
{
|
||||
|
||||
worksheet.Name = string.Format("{0}", haltung.Stammdaten.Objektbezeichnung);
|
||||
|
||||
int wiederholungen = 3;
|
||||
int row = 1;
|
||||
|
||||
for (int i = 0; i < wiederholungen; i++)
|
||||
{
|
||||
int mainrow = row;
|
||||
worksheet.Range[row, 1].Text = "Haltung";
|
||||
worksheet.Range[row, 2].Text = "Länge";
|
||||
worksheet.Range[row, 3].Text = "Tiefe";
|
||||
worksheet.Range[row, 4].Text = "Inspizierte Länge";
|
||||
worksheet.Range[row, 5].Text = "Straße";
|
||||
worksheet.Range[row, 9].Text = "DN";
|
||||
worksheet.Range[row, 10].Text = "Material";
|
||||
|
||||
row++;
|
||||
worksheet.Range[row, 1].Text = haltung.Stammdaten.Objektbezeichnung;
|
||||
worksheet.Range[row, 2].Text = "TODO";
|
||||
worksheet.Range[row, 3].Text = "TODO";
|
||||
|
||||
worksheet.Range[row, 5].Text = haltung.Inspektionsdaten.Lage.Strassename;
|
||||
worksheet.Range[row, 9].Text = haltung.Inspektionsdaten.OptischeInspektion[0].Rohrleitung.Grunddaten.Profilbreite.ToString();
|
||||
worksheet.Range[row, 10].Text = haltung.Inspektionsdaten.OptischeInspektion[0].Rohrleitung.Grunddaten.Material.ToString();
|
||||
|
||||
worksheet.Range[mainrow,1,row,10].CellStyle = cellStyle;
|
||||
|
||||
row += 4;
|
||||
int temprow = row;
|
||||
worksheet.Range[row, 1].Text = "Stat";
|
||||
worksheet.Range[row, 2].Text = "Kürzel";
|
||||
worksheet.Range[row, 3].Text = "Charakterisierung";
|
||||
worksheet.Range[row, 4].Text = "Quantifizierung";
|
||||
worksheet.Range[row, 5].Text = "Lage";
|
||||
worksheet.Range[row, 6].Text = "Verb.";
|
||||
worksheet.Range[row, 7].Text = "Schaden";
|
||||
worksheet.Range[row, 8].Text = "Strecke";
|
||||
worksheet.Range[row, 9].Text = "Sanierung";
|
||||
worksheet.Range[row, 10].Text = "Kosten";
|
||||
|
||||
row++;
|
||||
//int rows = 7;
|
||||
decimal inspizierteLaenge = 0m;
|
||||
for (int j = 0; j < haltung.Inspektionsdaten.OptischeInspektion.Count; j++)
|
||||
{
|
||||
OptischeInspektion opt = haltung.Inspektionsdaten.OptischeInspektion[j];
|
||||
inspizierteLaenge += opt.Rohrleitung.Zustaende.Max(x => x.Station);
|
||||
foreach (RZustand code in opt.Rohrleitung.Zustaende)
|
||||
{
|
||||
worksheet.Range[row + j, 1].Text = code.Station.ToString();
|
||||
worksheet.Range[row + j, 2].Text = code.Inspektionskode;
|
||||
string ch = "";
|
||||
if (code.Charakterisierung1 != null)
|
||||
ch = code.Charakterisierung1;
|
||||
if (code.Charakterisierung2 != null)
|
||||
ch = string.Format("{0} / {1}", ch, code.Charakterisierung2);
|
||||
worksheet.Range[row + j, 3].Text = ch;
|
||||
|
||||
worksheet.Range[row + j, 4].Text = code.Quantifizierung1.ToString();
|
||||
|
||||
string pos = "";
|
||||
if (code.PositionVon != 0)
|
||||
pos = code.PositionVon.ToString();
|
||||
if (code.PositionBis != 0)
|
||||
pos = string.Format("{0} - {1}", pos, code.PositionBis);
|
||||
worksheet.Range[row + j, 5].Text = pos;
|
||||
|
||||
if (code.Verbindung)
|
||||
worksheet.Range[row + j, 6].Text = "JA";
|
||||
|
||||
worksheet.Range[row + j, 7].Text = code.KodeDescription;
|
||||
worksheet.Range[row + j, 8].Text = code.Streckenschaden;
|
||||
worksheet.Range[row + j, 9].Text = "";
|
||||
worksheet.Range[row + j, 10].Text = "";
|
||||
row++;
|
||||
}
|
||||
}
|
||||
worksheet.Range[mainrow+1, 4].Text = inspizierteLaenge.ToString();
|
||||
worksheet.Range[temprow, 1, row, 10].CellStyle = cellStyle;
|
||||
row += 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user