Getting Exception in Cell

Hi Team,


We added the code which is available in code changes.png Screen shot based on the suggestions given in the earlier post.(Regarding checkcell functionality in 8.3.4 aspose version).

It Resolved the problem but its creating issues in the attached SS highlighted area.Because its changing the decimal value to rounded value in some cells.(0.69 to 1) and getting #### value in cell because of this fix…Kindly provide me the solution to solve this issue.




Hi Saravanan,


Thank you for contacting Aspose support.

I have checked your provided snapshots, and I am able to spot only the problem related to the cell values being displayed as #### in columns LOS, SET, SFR & TOTAL. This problem is caused due to the reason that cell width is too small to display the complete number value, and it can be easily corrected by using the Worksheet.autoFitColumns method just before saving the spreadsheet. Regarding the other two points as mentioned below, we need an executable standalone sample application along with supporting documents to replicate & investigate the matters.

  • You have mentioned that you are getting some exception (probably NullPointerException) but you haven’t shared any exception details/Stack Trace or the statement that is causing it. We need more details to look further into this matter.
  • You have mentioned that value 0.69 is being treated as 1, we need sample spreadsheet & code to isolate the problem cause.

Everything is working fine if we will not apply the fix which was given by Aspose forum to solve the exponential value issue.So is there any solution to solve exponential issue without affecting other cell?


The code we changed in existing code for exponential Problem is,
/**
* Get the value in the cell on the specified index for the current cell
* set.
*
* @param attributeIndex The index of the value in current cell set.
* @param valueType The value type as defined by the
* {@link com.tms.rundown.common.report.io.cell.CellValueType}
* interface.
* @return cell value
*/
private Object getValueByIndex(int attributeIndex, CellValueType valueType)
{
if (!isValidRow())
{
// VEH00059535 - Lates Aspose changes - start
throw new IllegalArgumentException(" The row pointer [" + rowIndex + “] for the page Id + [”
+ cellSetMetaData.getContainedPageId() + “] with Range Name: [” + sectionRange.getName()
+ “] is invalid.”);
// VEH00059535 - Lates Aspose changes - end
}

if (attributeIndex > getAttributeCount())
{
// VEH00059535 - Lates Aspose changes - start
throw new IllegalArgumentException(" The attributeIndex [" + attributeIndex + "] for the page Id + " + “[”
+ cellSetMetaData.getContainedPageId() + “] with Range Name: [” + sectionRange.getName()
+ “] is invalid.”);
// VEH00059535 - Lates Aspose changes - end
}

Object returnData = null;

// The row and the column indexes that are decided based on orientation.
int absoluteRowId = getAbsoluteRowId(attributeIndex);
int absoluteColumnId = getAbsoluteColumnId(attributeIndex);
// VEH00059535 - Lates Aspose changes - start
Cell cell = sectionRange.getWorksheet().getCells().checkCell(absoluteRowId, absoluteColumnId);
Style style = cell.getStyle();
style.setNumber(1);
StyleFlag flag = new StyleFlag();
flag.setNumberFormat(true);
cell.setStyle(style, flag);

//Cell cell = sectionRange.getCellOrNull(absoluteRowId - sectionRange.getFirstRow(), absoluteColumnId - sectionRange.getFirstColumn());
// VEH00059535 - Lates Aspose changes - end

if (cell != null)
{
// Based on the type of value expected the
// same is being returned.
if (CellValueType.NATIVE.equals(valueType))
{
returnData = cell.getValue();
}
else if (CellValueType.FORMATTED.equals(valueType))
{
returnData = cell.getStringValue();
}
}

// convert the Null to the blank string otherwise NULL will be displayed
// on the screen.
if (returnData == null)
{
returnData = “”;
}

return returnData;
}

Hi Saravanan,


Thank you for writing back.

I am sorry, I am still not sure of your narrated problem. I have gone through the complete thread, and all we have suggested there is to apply the number format on the column T in order to fix the problem of exponential values. This should not trigger changes to any other cell values unless cells from the column T are being referenced somewhere else in the spreadsheet as a parameter to some formula. I have also checked the sample spreadsheet shared here, and I couldn’t find the references to cells from column T in it so I guess the sample is no more applicable for your recent concerns.

Regarding your code snippet, there are a lot of dependencies that I cannot figure out on my own that is the reason I have been asking for a sample application to first replicate the problem on my side, and in case the problem persists with latest revision of the API, I have to pass that on to the product team for further analysis and correction purposes. Please be kind enough to create a simple sample application (covering your complete scenario, if possible) and share it here along with input spreadsheet(s) to replicate both mentioned problems. Before you move forward to provide the above requested, please give a try to the latest version of the API, that is; 8.6.3.2 at the moment, just to make sure the presented problems are not version specific.

I hope you are able to fix the issue related to the cell values being displayed as ##### by using Worksheet.autoFitColumns method.