BigInteger in cell values

Hi,


Using the Java version of Cells, I get an error trying to set a cell’s value with a BigInteger (the stacktrace looks odd because it’s running in Jython):
java.lang.IllegalArgumentException: Unknown value type[java.math.BigInteger]
at com.aspose.cells.Cell.setValue(Unknown Source)
at com.aspose.cells.Cells.importCollection(Unknown Source)

Is there anything I can do to have setValue support BigInteger? Or would converting it to a string work?

Thanks!

Steve

Hi Steve,

Converting it to string will definitely work.

And if you want to get a support for Big Integer, then please provide me your Java code example and also attach here input xls/xlsx file containing a big integer which you can create manually using Ms-Excel.

Hi Shakeel,


Thanks - we’ll use strings for now. Test case is below if your engineers want to take a look at it. The attached xlsx file has a large integer in cell A1 but I don’t know how Excel is representing it internally (the format is ‘General’).

> cat aspose_bigint.java

import com.aspose.cells.*;
import java.math.BigInteger;

class aspose_bigint {
public static void main(String args[]) {
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().addSheet();

BigInteger bigint = new BigInteger(“1099511627776”); // 2 ^ 40
Cells cells = worksheet.getCells();
Cell cell = cells.getCell(“A1”);
cell.setValue(bigint);
try { workbook.save(“bigint.xls”); }
catch (Exception e) {}
}
}

> javac -cp .:aspose-cells-2.4.1.jar aspose_bigint.java
> java -cp .:aspose-cells-2.4.1.jar aspose_bigint
Exception in thread “main” java.lang.IllegalArgumentException: Unknown value type[java.math.BigInteger]
at com.aspose.cells.Cell.setValue(Unknown Source)
at aspose_bigint.main(aspose_bigint.java:13)

Hi,

Such kind of number will be taken as double value in excel, and you may use Cell.setValue(1099511627776.) too to assign it to a cell.