When reading a file with a formula that divides by zero, an excel prompt of "Warning:data may be lost" is presented to the user.
Created attachment 5411 [details] Excel File (Pre-poi)
public class POITest { public static void main(String[] args) throws IOException { File file = new File("divbug.xls"); InputStream input = new FileInputStream(file); HSSFWorkbook wb = new HSSFWorkbook(input); input.close(); File outFile = new File("divbug-poi.xls"); outFile.createNewFile(); OutputStream output = new FileOutputStream(outFile); wb.write(output); output.close(); } }
Interesting, to say the least. I think the issue is in an ErrorPtg that poi does not yet handle. It should be simple to add these to poi, since they wouldnt affect the formula parser.. you just have to read them and spit them out whenever necessary. The only issue is the tediousness of implementing all the ErrorPtg classes.
i was hoping it was simple (didnt look at it yet) but tedious ack. you do what you have to do..
Apparently our LittleEndian NaN support didn't create a suitable value when fillingFields for a FormulaRecord with my Excel version (2000). When we created a workbook from scratch with a div by zero formula, the value is 0 and not NaN. The fix was to preserve Excel's NaN representation and serialize it out again when using fillFields.