Export Grid to Excel with text wrap

Is there a way to preserve the onscreen text wrap layout when exporting to Excel?  It would be great of text wrap could be preserved.  


1 Reply

TS Thiyagu Subramani Syncfusion Team September 21, 2021 01:36 AM UTC

Hi William, 

Thanks for contacting Syncfusion support. 

Based on your query you need to wrap the text while exporting to Excel. In this we can wrap the long text cells value to adopt within the cells using the Grid column’s width and wrapText style property of Excel sheet 

But, we cannot wrap the overlapping text in Excel cell based on comma operator. To achieve the requirement in the CustomerID we suggest you to use excelQueryCellInfo event and column.width property. 

In excelQueryCellInfo event we have defined the wrapText style property as true then text content will wrap to the next line when content exceeds the width of the Excel Column Cells. 

Please refer the below code example and sample for more information. 

 
methods: { 
    excelQueryCellInfo: function (args) { 
       if(args.column.field === "CustomerID"){ 
           args.style = { wrapText:true }; 
        } 
    }, 
  }, 
 
  <template> 
  <div id="app"> 
    <ejs-grid 
      . . . . .  . 
      : excelQueryCellInfo =" excelQueryCellInfo" 
    > 
      <e-columns> 
. . . . .  
        <e-column 
          field="CustomerID" 
          headerText="Customer Name" 
          width="50" 
        ></e-column> 
      </e-columns> 
    </ejs-grid> 
  </div> 
</template> 


                                       https://ej2.syncfusion.com/documentation/api/grid/excelStyle/#wraptext 

Please get back to us, if you need further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon