If tests when having emty cells are not evaluated as in excel

Last post 11-18-2009, 6:45 AM by aspose.notifier. 4 replies.
Sort Posts: Previous Next
  •  11-09-2009, 10:56 AM 206571

    If tests when having emty cells are not evaluated as in excel Java

    Attachment: Present (inaccessible)
    When we have the formula
    • =IF(A1=""; "Empty"; "Not empty")

    This is evaluated as in Excel if we
    • Have a value
    • Explicitly set value to emty string ""

    It is not evaluated as in Excel if we
    • clear the cell in Excel
    • clear the cell by code:  inputs.getCells().getCell("A1").clearContent();

    Test code:

    import java.io.FileInputStream;
    import java.io.IOException;

    import com.aspose.cells.AsposeLicenseException;
    import com.aspose.cells.License;
    import com.aspose.cells.Workbook;
    import com.aspose.cells.Worksheet;

    public class EmptyIfTest {

        public static void main(String[] args) throws IOException, AsposeLicenseException {
           
               License lic = new License();
               lic.setLicense(new FileInputStream("lib/Aspose.Cells.lic"));
              
               Workbook workbook = new Workbook(); 

               workbook.open("Excel/emptyiftest.xls");
             
               Worksheet inputs = workbook.getWorksheets().getSheet("Inputs");
              
               inputs.getCells().getCell("A1").clearContent();
               inputs.getCells().getCell("A3").setValue("");

               workbook.calculateFormula();
              
               System.out.println("A1: "+inputs.getCells().getCell("A1").getValue());
               System.out.println("B1: "+inputs.getCells().getCell("B1").getValue());
               System.out.println("B1 formula: " + inputs.getCells().getCell("B1").getFormula());

               System.out.println("A2: "+inputs.getCells().getCell("A2").getValue());
               System.out.println("B2: "+inputs.getCells().getCell("B2").getValue());
               System.out.println("B2 formula: " + inputs.getCells().getCell("B2").getFormula());
              
               System.out.println("A3: "+inputs.getCells().getCell("A3").getValue());
               System.out.println("B3: "+inputs.getCells().getCell("B3").getValue());
               System.out.println("B3 formula: " + inputs.getCells().getCell("B3").getFormula());
              
               workbook.save("Excel/Result.xls");
              
        }

    }

    If you compare the output with the Result.xls file you will find the B1 cell evaluated to "Empty" in the excel spreadsheet but to "Not empty" in the console output.


    Filed under: Aspose.Cells bug
     
  •  11-09-2009, 12:43 PM 206594 in reply to 206571

    Re: If tests when having emty cells are not evaluated as in excel

    Hi, 

     

    Thank you for considering Aspose.

     

    Well, Cell.clearContent() sets the value of a cell as null (not “”). That is why “B1” cells value comes as “Not Empty”. Anyways, we will further look into your issue and get back to you soon. Also, I have added your issue to our issue tracking system with issue id CELLSJAVA-11665.

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  11-10-2009, 1:42 AM 206713 in reply to 206571

    Re: If tests when having emty cells are not evaluated as in excel

    Attachment: Present (inaccessible)

    Hi, 

     

    Thank you for considering Aspose.

     

    Please try the attached latest version of Aspose.Cells. We have fixed the issue for comparing empty string "" with empty cells.

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  11-10-2009, 6:57 AM 206807 in reply to 206713

    Re: If tests when having emty cells are not evaluated as in excel

    Now it works fine. Thank you
     
  •  11-18-2009, 6:45 AM 208586 in reply to 206571

    Re: If tests when having emty cells are not evaluated as in excel

    The issues you have found earlier (filed as 11665) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
View as RSS news feed in XML