ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.How to change Excel direction to RTL when exporting using OpenXML in ASP.Net<p>Hi,</p> <p>Please refer below code</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:GridView ID=&#34;GridView1&#34; HeaderStyle-BackColor=&#34;#3AC0F2&#34; HeaderStyle-ForeColor=&#34;White&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;Id&#34; HeaderText=&#34;Id&#34; ItemStyle-Width=&#34;30&#34; /&gt; &lt;asp:BoundField DataField=&#34;Name&#34; HeaderText=&#34;Name&#34; ItemStyle-Width=&#34;150&#34; /&gt; &lt;asp:BoundField DataField=&#34;Country&#34; HeaderText=&#34;Country&#34; ItemStyle-Width=&#34;150&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;br /&gt; &lt;asp:Button Text=&#34;Export&#34; OnClick=&#34;ExportExcel&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn(&#34;Id&#34;, typeof(int)), new DataColumn(&#34;Name&#34;, typeof(string)), new DataColumn(&#34;Country&#34;,typeof(string)) }); dt.Rows.Add(1, &#34;انگریزی نہیں&#34;, &#34;ے ایڈیٹر&#34;); dt.Rows.Add(2, &#34;یہ انگریزی&#34;, &#34; کو استعمال&#34;); dt.Rows.Add(3, &#34;نہیں&#34;, &#34;تمام لکھائی&#34;); dt.Rows.Add(4, &#34;یہ&#34;, &#34;ے ایڈیٹر&#34;); GridView1.DataSource = dt; GridView1.DataBind(); } } protected void ExportExcel(object sender, EventArgs e) { DataTable dt = new DataTable(&#34;GridView_Data&#34;); foreach (TableCell cell in GridView1.HeaderRow.Cells) { dt.Columns.Add(cell.Text); } foreach (GridViewRow row in GridView1.Rows) { dt.Rows.Add(); for (int i = 0; i &lt; row.Cells.Count; i++) { dt.Rows[dt.Rows.Count - 1][i] = row.Cells[i].Text; } } using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt); wb.Worksheets.FirstOrDefault().RightToLeft = true; Response.Clear(); Response.Buffer = true; Response.Charset = &#34;&#34;; Response.ContentType = &#34;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&#34;; Response.AddHeader(&#34;content-disposition&#34;, &#34;attachment;filename=GridView.xlsx&#34;); using (MemoryStream MyMemoryStream = new MemoryStream()) { wb.SaveAs(MyMemoryStream); MyMemoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.End(); } } }</pre> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><span style="text-decoration: underline;">1)</span></p> <p><img src="https://i.imgur.com/ltrOYr6.png" alt="" width="349" height="174" /></p> <p><span style="text-decoration: underline;">2)</span></p> <p><img src="https://i.imgur.com/esR47u2.png" alt="" width="358" height="373" /></p>https://www.aspforums.net:443/Threads/163276/How-to-change-Excel-direction-to-RTL-when-exporting-using-OpenXML-in-ASPNet/https://www.aspforums.net:443/Threads/163276/How-to-change-Excel-direction-to-RTL-when-exporting-using-OpenXML-in-ASPNet/Thu, 09 Jun 2016 07:51:14 GMT