Search in sources :

Example 61 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project org.hl7.fhir.core by hapifhir.

the class XLSXWriter method dump.

public void dump() throws IOException {
    for (int i = 0; i < 34; i++) {
        sheet.autoSizeColumn(i);
    }
    sheet.setColumnHidden(2, true);
    sheet.setColumnHidden(3, true);
    sheet.setColumnHidden(30, true);
    sheet.setColumnHidden(31, true);
    sheet.setColumnHidden(32, true);
    sheet.setColumnWidth(9, columnPixels(20));
    sheet.setColumnWidth(11, columnPixels(100));
    sheet.setColumnWidth(12, columnPixels(100));
    sheet.setColumnWidth(13, columnPixels(100));
    sheet.setColumnWidth(15, columnPixels(20));
    sheet.setColumnWidth(16, columnPixels(20));
    sheet.setColumnWidth(17, columnPixels(20));
    sheet.setColumnWidth(18, columnPixels(20));
    sheet.setColumnWidth(34, columnPixels(100));
    int i = titles.length - 1;
    for (StructureDefinitionMappingComponent map : def.getMapping()) {
        i++;
        sheet.setColumnWidth(i, columnPixels(50));
        sheet.autoSizeColumn(i);
    // sheet.setColumnHidden(i,  true);
    }
    sheet.createFreezePane(2, 1);
    if (hideMustSupportFalse) {
        SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
        String address = "A2:AI" + Math.max(Integer.valueOf(sheet.getLastRowNum()), 2);
        CellRangeAddress[] regions = { CellRangeAddress.valueOf(address) };
        ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("$G2<>\"Y\"");
        PatternFormatting fill1 = rule1.createPatternFormatting();
        fill1.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.index);
        fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
        ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("$Q2<>\"\"");
        FontFormatting font = rule2.createFontFormatting();
        font.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
        font.setFontStyle(true, false);
        sheetCF.addConditionalFormatting(regions, rule1, rule2);
        sheet.setAutoFilter(new CellRangeAddress(0, sheet.getLastRowNum(), 0, titles.length + def.getMapping().size() - 1));
        XSSFSheet xSheet = (XSSFSheet) sheet;
        CTAutoFilter sheetFilter = xSheet.getCTWorksheet().getAutoFilter();
        CTFilterColumn filterColumn1 = sheetFilter.addNewFilterColumn();
        filterColumn1.setColId(6);
        CTCustomFilters filters = filterColumn1.addNewCustomFilters();
        CTCustomFilter filter1 = filters.addNewCustomFilter();
        filter1.setOperator(STFilterOperator.NOT_EQUAL);
        filter1.setVal(" ");
        CTFilterColumn filterColumn2 = sheetFilter.addNewFilterColumn();
        filterColumn2.setColId(26);
        CTFilters filters2 = filterColumn2.addNewFilters();
        filters2.setBlank(true);
        // We have to apply the filter ourselves by hiding the rows:
        for (Row row : sheet) {
            if (row.getRowNum() > 0 && (!row.getCell(6).getStringCellValue().equals("Y") || !row.getCell(26).getStringCellValue().isEmpty())) {
                ((XSSFRow) row).getCTRow().setHidden(true);
            }
        }
    }
    sheet.setActiveCell(new CellAddress(sheet.getRow(1).getCell(0)));
    wb.write(outStream);
    flush();
    close();
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionMappingComponent) CTAutoFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter) ConditionalFormattingRule(org.apache.poi.ss.usermodel.ConditionalFormattingRule) FontFormatting(org.apache.poi.ss.usermodel.FontFormatting) PatternFormatting(org.apache.poi.ss.usermodel.PatternFormatting) CellAddress(org.apache.poi.ss.util.CellAddress) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) CTFilterColumn(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilterColumn) SheetConditionalFormatting(org.apache.poi.ss.usermodel.SheetConditionalFormatting) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) CTCustomFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilters) CTCustomFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilter) CTFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilters)

Example 62 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project org.hl7.fhir.core by hapifhir.

the class XLSXWriter method dump.

public void dump() throws IOException {
    for (int i = 0; i < 34; i++) {
        sheet.autoSizeColumn(i);
    }
    sheet.setColumnHidden(2, true);
    sheet.setColumnHidden(3, true);
    sheet.setColumnHidden(30, true);
    sheet.setColumnHidden(31, true);
    sheet.setColumnHidden(32, true);
    sheet.setColumnWidth(9, columnPixels(20));
    sheet.setColumnWidth(11, columnPixels(100));
    sheet.setColumnWidth(12, columnPixels(100));
    sheet.setColumnWidth(13, columnPixels(100));
    sheet.setColumnWidth(15, columnPixels(20));
    sheet.setColumnWidth(16, columnPixels(20));
    sheet.setColumnWidth(17, columnPixels(20));
    sheet.setColumnWidth(18, columnPixels(20));
    sheet.setColumnWidth(34, columnPixels(100));
    int i = titles.length - 1;
    for (StructureDefinitionMappingComponent map : def.getMapping()) {
        i++;
        sheet.setColumnWidth(i, columnPixels(50));
        sheet.autoSizeColumn(i);
    // sheet.setColumnHidden(i,  true);
    }
    sheet.createFreezePane(2, 1);
    if (hideMustSupportFalse) {
        SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
        String address = "A2:AI" + Math.max(Integer.valueOf(sheet.getLastRowNum()), 2);
        CellRangeAddress[] regions = { CellRangeAddress.valueOf(address) };
        ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("$G2<>\"Y\"");
        PatternFormatting fill1 = rule1.createPatternFormatting();
        fill1.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.index);
        fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
        ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("$Q2<>\"\"");
        FontFormatting font = rule2.createFontFormatting();
        font.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
        font.setFontStyle(true, false);
        sheetCF.addConditionalFormatting(regions, rule1, rule2);
        sheet.setAutoFilter(new CellRangeAddress(0, sheet.getLastRowNum(), 0, titles.length + def.getMapping().size() - 1));
        XSSFSheet xSheet = (XSSFSheet) sheet;
        CTAutoFilter sheetFilter = xSheet.getCTWorksheet().getAutoFilter();
        CTFilterColumn filterColumn1 = sheetFilter.addNewFilterColumn();
        filterColumn1.setColId(6);
        CTCustomFilters filters = filterColumn1.addNewCustomFilters();
        CTCustomFilter filter1 = filters.addNewCustomFilter();
        filter1.setOperator(STFilterOperator.NOT_EQUAL);
        filter1.setVal(" ");
        CTFilterColumn filterColumn2 = sheetFilter.addNewFilterColumn();
        filterColumn2.setColId(26);
        CTFilters filters2 = filterColumn2.addNewFilters();
        filters2.setBlank(true);
        // We have to apply the filter ourselves by hiding the rows:
        for (Row row : sheet) {
            if (row.getRowNum() > 0 && (!row.getCell(6).getStringCellValue().equals("Y") || !row.getCell(26).getStringCellValue().isEmpty())) {
                ((XSSFRow) row).getCTRow().setHidden(true);
            }
        }
    }
    sheet.setActiveCell(new CellAddress(sheet.getRow(1).getCell(0)));
    wb.write(outStream);
    flush();
    close();
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent) CTAutoFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter) ConditionalFormattingRule(org.apache.poi.ss.usermodel.ConditionalFormattingRule) FontFormatting(org.apache.poi.ss.usermodel.FontFormatting) PatternFormatting(org.apache.poi.ss.usermodel.PatternFormatting) CellAddress(org.apache.poi.ss.util.CellAddress) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) CTFilterColumn(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilterColumn) SheetConditionalFormatting(org.apache.poi.ss.usermodel.SheetConditionalFormatting) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) CTCustomFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilters) CTCustomFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilter) CTFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilters)

Example 63 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project org.hl7.fhir.core by hapifhir.

the class CodeSystemSpreadsheetGenerator method genExpansionParams.

private void genExpansionParams(List<ValueSetExpansionParameterComponent> params) {
    Sheet sheet = makeSheet("Expansion Parameters");
    addHeaders(sheet, "Parameter", "Value");
    for (ValueSetExpansionParameterComponent p : params) {
        addRow(sheet, p.getName(), dr.display(p.getValue()));
    }
}
Also used : ValueSetExpansionParameterComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent) Sheet(org.apache.poi.ss.usermodel.Sheet)

Example 64 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project org.hl7.fhir.core by hapifhir.

the class StructureDefinitionSpreadsheetGenerator method renderStructureDefinition.

public StructureDefinitionSpreadsheetGenerator renderStructureDefinition(StructureDefinition sd) throws Exception {
    if (sd == null) {
        System.out.println("no structure!");
    }
    if (!sd.hasSnapshot()) {
        throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT));
    }
    addStructureDefinitionMetadata(renderCanonicalResource(sd), sd);
    Sheet sheet = makeSheet("Elements");
    Row headerRow = sheet.createRow(0);
    for (int i = 0; i < titles.length; i++) {
        addCell(headerRow, i, titles[i], styles.get("header"));
    }
    int i = titles.length - 1;
    for (StructureDefinitionMappingComponent map : sd.getMapping()) {
        i++;
        addCell(headerRow, i, "Mapping: " + map.getName(), styles.get("header"));
    }
    for (ElementDefinition child : sd.getSnapshot().getElement()) {
        processElement(sheet, sd, child);
    }
    configureSheet(sheet, sd);
    return this;
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionMappingComponent) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) ElementDefinition(org.hl7.fhir.r4b.model.ElementDefinition) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet)

Example 65 with Sheet

use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project org.hl7.fhir.core by hapifhir.

the class CanonicalSpreadsheetGenerator method renderCanonicalResource.

protected Sheet renderCanonicalResource(CanonicalResource cr) {
    Sheet sheet = makeSheet("Metadata");
    Row headerRow = sheet.createRow(0);
    addCell(headerRow, 0, "Property", styles.get("header"));
    addCell(headerRow, 1, "Value", styles.get("header"));
    addMetadataRow(sheet, "URL", cr.getUrl());
    for (Identifier id : cr.getIdentifier()) {
        addMetadataRow(sheet, "Identifier", dr.display(id));
    }
    addMetadataRow(sheet, "Version", cr.getVersion());
    addMetadataRow(sheet, "Name", cr.getName());
    addMetadataRow(sheet, "Title", cr.getTitle());
    addMetadataRow(sheet, "Status", cr.getStatusElement().asStringValue());
    addMetadataRow(sheet, "Experimental", cr.getExperimentalElement().asStringValue());
    addMetadataRow(sheet, "Date", cr.getDateElement().asStringValue());
    addMetadataRow(sheet, "Publisher", cr.getPublisher());
    for (ContactDetail c : cr.getContact()) {
        addMetadataRow(sheet, "Contact", dr.display(c));
    }
    for (CodeableConcept j : cr.getJurisdiction()) {
        addMetadataRow(sheet, "Jurisdiction", dr.display(j));
    }
    addMetadataRow(sheet, "Description", cr.getDescription());
    addMetadataRow(sheet, "Purpose", cr.getPurpose());
    addMetadataRow(sheet, "Copyright", cr.getCopyright());
    configureSheet(sheet);
    return sheet;
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) Identifier(org.hl7.fhir.r5.model.Identifier) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)18 Sheet (org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet)15 Sheet (org.apache.poi.ss.usermodel.Sheet)14 Row (org.apache.poi.ss.usermodel.Row)13 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)12 ArrayList (java.util.ArrayList)8 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)8 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)8 Invariant (org.hl7.fhir.definitions.model.Invariant)8 XLSXmlParser (org.hl7.fhir.utilities.xls.XLSXmlParser)8 TypeRef (org.hl7.fhir.definitions.model.TypeRef)7 File (java.io.File)6 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)5 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)5 IniFile (org.hl7.fhir.utilities.IniFile)5 HashMap (java.util.HashMap)4 ConditionalFormattingRule (org.apache.poi.ss.usermodel.ConditionalFormattingRule)4 FontFormatting (org.apache.poi.ss.usermodel.FontFormatting)4 PatternFormatting (org.apache.poi.ss.usermodel.PatternFormatting)4 SheetConditionalFormatting (org.apache.poi.ss.usermodel.SheetConditionalFormatting)4