MCPcopy Index your code
hub / github.com/benfry/processing4 / odsParse

Method odsParse

core/src/processing/data/Table.java:858–898  ·  view source on GitHub ↗
(InputStream input, String worksheet, boolean header)

Source from the content-addressed store, hash-verified

856
857
858 protected void odsParse(InputStream input, String worksheet, boolean header) {
859 try {
860 InputStream contentStream = odsFindContentXML(input);
861 XML xml = new XML(contentStream);
862
863 // table files will have multiple sheets..
864 // <table:table table:name="Sheet1" table:style-name="ta1" table:print="false">
865 // <table:table table:name="Sheet2" table:style-name="ta1" table:print="false">
866 // <table:table table:name="Sheet3" table:style-name="ta1" table:print="false">
867 XML[] sheets =
868 xml.getChildren("office:body/office:spreadsheet/table:table");
869
870 boolean found = false;
871 for (XML sheet : sheets) {
872// System.out.println(sheet.getAttribute("table:name"));
873 if (worksheet == null || worksheet.equals(sheet.getString("table:name"))) {
874 odsParseSheet(sheet, header);
875 found = true;
876 if (worksheet == null) {
877 break; // only read the first sheet
878 }
879 }
880 }
881 if (!found) {
882 if (worksheet == null) {
883 throw new RuntimeException("No worksheets found in the ODS file.");
884 } else {
885 throw new RuntimeException("No worksheet named " + worksheet +
886 " found in the ODS file.");
887 }
888 }
889 } catch (UnsupportedEncodingException e) {
890 e.printStackTrace();
891 } catch (IOException e) {
892 e.printStackTrace();
893 } catch (ParserConfigurationException e) {
894 e.printStackTrace();
895 } catch (SAXException e) {
896 e.printStackTrace();
897 }
898 }
899
900
901 /**

Callers 1

parseMethod · 0.95

Calls 6

odsFindContentXMLMethod · 0.95
getChildrenMethod · 0.95
odsParseSheetMethod · 0.95
getStringMethod · 0.65
equalsMethod · 0.45
printStackTraceMethod · 0.45

Tested by

no test coverage detected