Search in sources :

Example 1 with SBlock

use of eu.ggnet.lucidcalc.SBlock in project dwoss by gg-net.

the class SFormulaTest method testFormulaError.

@Test
public void testFormulaError() {
    SFormula[] formulas = { new SFormula(33, "+", 22, "//"), new SFormula(33, "+", 2, "/", 0), new SFormula(33, "+", 22, "/", Double.NaN), new SFormula(33, "+", 22), new SFormula(33, "+", 22) };
    STable newTable = new STable();
    newTable.add(new STableColumn("TestFormula", 10));
    newTable.setModel(new STableModelList<>(formulas));
    SBlock block = new SBlock();
    block.add(new SFormula("SUMME(", newTable.getCellFirstRow(0), ":", newTable.getCellLastRow(0), ")"));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Sheet1", newTable, block));
    File f = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    f.delete();
// System.out.println(f.toURI());
// No assert needed. If Anything goes wrong in the write process, an exception would be thrown.
}
Also used : STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) SFormula(eu.ggnet.lucidcalc.SFormula) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) SBlock(eu.ggnet.lucidcalc.SBlock) File(java.io.File) Test(org.junit.Test)

Example 2 with SBlock

use of eu.ggnet.lucidcalc.SBlock in project dwoss by gg-net.

the class ReturnsExporter method returnsToXls.

public static File returnsToXls(List<ReportLine> lines) {
    List<Object[]> linesData = new ArrayList<>();
    for (ReportLine reportLine : lines) {
        Object[] data = new Object[] { reportLine.getDossierIdentifier(), reportLine.getActual(), reportLine.getRefurbishId(), reportLine.getPartNo(), reportLine.getName(), reportLine.getSerial(), reportLine.getMfgDate(), reportLine.getReportingDate() };
        linesData.add(data);
    }
    STable newTable = new STable();
    newTable.setTableFormat(new CFormat("Verdana", 10, new CBorder(Color.BLACK, CBorder.LineStyle.THIN)));
    newTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.CENTER, CFormat.VerticalAlignment.MIDDLE));
    newTable.add(new STableColumn("Auftrag", 15));
    newTable.add(new STableColumn("Datum", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.add(new STableColumn("SopoNr", 10));
    newTable.add(new STableColumn("ArtikelNr", 15));
    newTable.add(new STableColumn("Bezeichnung", 40));
    newTable.add(new STableColumn("Seriennummer", 35));
    newTable.add(new STableColumn("MFGDate", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.add(new STableColumn("reported Am", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.setModel(new STableModelList<>(linesData));
    STable table = new STable(newTable);
    table.setModel(new STableModelList<>(linesData));
    ReturnsExporter.SResult summary = createReturnsSummary(table, lines.size());
    SBlock block = new SBlock();
    block.setFormat(new CFormat(Color.BLACK, Color.LIGHT_GRAY, CFormat.HorizontalAlignment.LEFT));
    block.add(new SCell("Rückläufer"), "");
    CSheet sheet = new CSheet("Rückläufer Report");
    sheet.setShowGridLines(false);
    sheet.addBelow(block);
    sheet.addBelow(newTable);
    sheet.addBelow(4, 1, summary.block);
    CCalcDocument doc = new TempCalcDocument("Rückläufer");
    doc.add(sheet);
    LucidCalcWriter writer = LucidCalc.createWriter(LucidCalc.Backend.XLS);
    return writer.write(doc);
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SCell(eu.ggnet.lucidcalc.SCell) LucidCalcWriter(eu.ggnet.lucidcalc.LucidCalcWriter) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) SBlock(eu.ggnet.lucidcalc.SBlock) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder)

Example 3 with SBlock

use of eu.ggnet.lucidcalc.SBlock in project dwoss by gg-net.

the class ReturnsExporter method createReturnsSummary.

/**
 * Create the Summary Block at the End.
 * <p/>
 * @param table        The Stable where all the data exist.
 * @param startingDate the startnig date of the Report.
 * @param endingDate   the ending date of the Report.
 * @return a SResult Block with the Summary.
 */
static ReturnsExporter.SResult createReturnsSummary(STable table, int amount) {
    ReturnsExporter.SResult r = new ReturnsExporter.SResult();
    r.block = new SBlock();
    r.block.setFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.RIGHT, new CBorder(Color.BLACK)));
    r.sum1 = new SCell(new SFormula("SUMME(", amount, "*", 10, ")"), EURO);
    r.sum2 = new SCell(amount);
    r.block.add(r.sum1, r.sum2);
    return r;
}
Also used : SCell(eu.ggnet.lucidcalc.SCell) SFormula(eu.ggnet.lucidcalc.SFormula) CFormat(eu.ggnet.lucidcalc.CFormat) SBlock(eu.ggnet.lucidcalc.SBlock) CBorder(eu.ggnet.lucidcalc.CBorder)

Aggregations

SBlock (eu.ggnet.lucidcalc.SBlock)3 CBorder (eu.ggnet.lucidcalc.CBorder)2 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)2 CFormat (eu.ggnet.lucidcalc.CFormat)2 CSheet (eu.ggnet.lucidcalc.CSheet)2 SCell (eu.ggnet.lucidcalc.SCell)2 SFormula (eu.ggnet.lucidcalc.SFormula)2 STable (eu.ggnet.lucidcalc.STable)2 STableColumn (eu.ggnet.lucidcalc.STableColumn)2 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)2 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)1 LucidCalcWriter (eu.ggnet.lucidcalc.LucidCalcWriter)1 File (java.io.File)1 Test (org.junit.Test)1