Problem on Export to Excel

mrigyamrigya Member Posts: 124
Hi All,
Please tell me how can i Wrap the Text in Excel through coding using Data Item Excel Buffer while Exporting the Report to Excel.

Thanks
Mrigya

Comments

  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
      XlRange1.WrapText := true;
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • mrigyamrigya Member Posts: 124
    Will you please tell me what is this XlRange1

    Thanks
    Mrigya
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    XlRange1 is a variable of type Unknown Automation Server.Range
    (Excel automation)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Define a custom Function in excel buffer table (say wrap)

    Parameter
    RangeName --- Text --- 50

    Local variable to function
    Name --- DataType --- Subtype
    XlRange1 ---Automation --- 'Microsoft Excel 11.0 Object Library'.Range

    In wrap(RangeName : Text[50]) function
         XlRange1          := XlWrkSht.Range(RangeName);
         XlRange1.WrapText := True;
    

    So now your function is ready.. O:) you just need to use it.


    Just an example on how to use the function.....
        ExcelBuf.NewRow;
        ExcelBuf.AddColumn(,,,.....,,,......,,,); //whatever applies for you 
        ExcelBuf.StartRange;
        ExcelBuf.AddColumn(,,,.....,,,......,,,); 
        ExcelBuf.AddColumn(,,,.....,,,......,,,); 
        
        ExcelBuf.EndRange;
        ExcelBuf.CreateRange('RangeForWrappingText');
        ExcelBuf.wrap('RangeForWrappingText');
        //..................
        //..................  your code
    

    now you see the output.
    I hope It helps you.... :P
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
Sign In or Register to comment.