Search code examples
eclipsereportreportingbirt

birt report column autosize when exporting to excel


i have done a birt report and now i'm trying to format it , so i need some help please.

I have tried the fixed layout but is not what i want.

can i autosize column width corresponding to the length of data inside it? and when exporting to excel ,can i keep the same settings as above?

maybe something like this but using birt options:

if (dataSetRow["cell_name"]== null) { '' }
   else {
     function wrap(longStr,width)
      { 
       length = longStr.length;
      if(length <= width) 
          return longStr;
      return (longStr.substring(0, width) + "\n" + wrap(longStr.substring(width, length), width)); }         


     wrap( dataSetRow["cell_name"], 5 );

       }

Thank you.


Solution

  • i actually managed to solve my problem , best way i've found is using EXCELRenderOption

    RenderOption options=null;
    options = new EXCELRenderOption();  
    options.setOutputFormat("xls");
    options.setOption(IRenderOption.EMITTER_ID,"org.eclipse.birt.report.engine.emitter.nativexls");
    

    it will do the job for you.