Forum Discussion

kumar25's avatar
kumar25
New Contributor II
6 months ago
Solved

How to read .xlsb file

Hi I have to read data from .xlsb file. I tried to use Excel parser but it is throwing error.
  • robin's avatar
    6 years ago

    Hello @sg_sripathi, good question and yes this can be done.

    Inject the expression utility class:

    @Inject
    private ExpressionUtils expressionUtils;
    
    String pipeLabel;
    

    then in the configure() method:

    @Override
    public void configure(PropertyValues propertyValues)
                throws ConfigurationException {
      Document emptyDoc = documentUtility.newDocument();
      pipeLabel = expressionUtils.createExpressionProperty(
      propertyValues, true, "pipe.label").eval(emptyDoc);
    }
    

    And then you can just use the variable when writing an output document e.g.:

    Map<String, String> data = new LinkedHashMap<String, String>() {{
      put("pipeLabel", pipeLabel);
    }};
    outputViews.write(documentUtility.newDocument(data));
    

    The Mapper Snap can be used to validate whatever expression value you are trying to use in the custom Snap: