}
private double rkNumber(byte[] data, int offset) {
- //see 2.5.122 for this abomination
+ //see 2.5.122
byte b0 = data[offset];
- String s = Integer.toString(b0, 2);
boolean numDivBy100 = ((b0 & 1) == 1); // else as is
boolean floatingPoint = ((b0 >> 1 & 1) == 0); // else signed integer
if (floatingPoint) {
d = LittleEndian.getDouble(rkBuffer);
} else {
- d = LittleEndian.getInt(rkBuffer);
+ int rawInt = LittleEndian.getInt(rkBuffer, 4);
+ d = rawInt >> 2;//divide by 4/shift bits coz 30 bit int, not 32
}
d = (numDivBy100) ? d/100 : d;
return d;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.Test;
+import java.io.BufferedReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
/**
* Tests for {@link XSSFBEventBasedExcelExtractor}
*/
"This is an example spreadsheet created with Microsoft Excel 2007 Beta 2.");
}
+ @Test
+ public void test62815() throws Exception {
+ //test file based on http://oss.sheetjs.com/test_files/RkNumber.xlsb
+ XSSFEventBasedExcelExtractor extractor = getExtractor("62815.xlsb");
+ extractor.setIncludeCellComments(true);
+ String[] rows = extractor.getText().split("[\r\n]+");
+ assertEquals(283, rows.length);
+ BufferedReader reader = Files.newBufferedReader(XSSFTestDataSamples.getSampleFile("62815.xlsb.txt").toPath(),
+ StandardCharsets.UTF_8);
+ String line = reader.readLine();
+ for (int i = 0; i < rows.length; i++) {
+ assertEquals(line, rows[i]);
+ line = reader.readLine();
+ while (line != null && line.startsWith("#")) {
+ line = reader.readLine();
+ }
+ }
+ }
+
}