We have a sheet that has a drop down (shape) with 2 items and a blank.
one cell is the index of the selected value. You can type in 0, 1, or 2 to change what is selected
we have a cell that tells us what value you picked from the list of elements.
I have a very abbreviated set of lines of code to exemplify the PDF export I will include here. I will also include the sheet in two conditions. The first is the error condition and the second is the case where an element is selected and no error is thrown.
import com.aspose.cells.SaveFormat;
import com.aspose.cells.ShapeCollection;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
public class IBM_to_Aspose {
static String badFile = "C:\\temp\\listStartsBlank.xlsx";
static String goodFile = "C:\\temp\\listStartsSelected.xlsx";
public static void main(String[] args) {
try {
// Test against both goodFile and badFile to compare
saveAsPDF(badFile);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void saveAsPDF(String fileName) throws Exception {
// Stepping through "same code" as in our real code base leading up to situation
Workbook workbook = new Workbook(fileName);
Workbook asposeUpdatedWorkbook = new Workbook();
asposeUpdatedWorkbook.copy(workbook);
Worksheet asposeUpdatedSheet;
for (int i=0; i<asposeUpdatedWorkbook.getWorksheets().getCount(); i++) {
asposeUpdatedSheet = asposeUpdatedWorkbook.getWorksheets().get(i);
ShapeCollection asposeShapes = asposeUpdatedSheet.getShapes();
// This is where in our code things go amok but we cannot just remove this line to "make it work"
// as it has purpose in our product.
asposeShapes.updateSelectedValue();
}
asposeUpdatedWorkbook.save("IBM_147434.pdf", SaveFormat.PDF);
System.out.println("Export saved successfully");
}
}IBM_to_Aspose.zip (37.1 KB)