在AR 15中,字段太长,导致导出的excel出现自动换行的问题,如何可以解决?
这是我的后台代码
- public partial class Index : System.Web.UI.Page
- {
- private EmpReport empReport;
- protected void Page_Load(object sender, EventArgs e)
- {
- empReport = new EmpReport();
- empReport.DataSource = this.GetEmpData();
- empReport.Run();
- this.webViewer.Report = empReport;
- }
- private DataTable GetEmpData() {
- var dt = new DataTable();
- dt.Columns.Add("EmpId", typeof(int));
- dt.Columns.Add("EmpName", typeof(string));
- dt.Columns.Add("EmpClient", typeof(string));
- for (int i = 0; i < 10; i++)
- {
- dt.Rows.Add(i, $"emp-{i}",$"client-{i}");
- }
- dt.Rows[8]["EmpClient"] = "very long very longvery long very long";
- return dt;
- }
- protected void btnExport_Click(object sender, EventArgs e)
- {
- empReport = new EmpReport();
- empReport.DataSource = this.GetEmpData();
- empReport.Run();
- XlsExport xlsExport = new XlsExport();
- var stream = new MemoryStream();
- xlsExport.AutoRowHeight = true;
- xlsExport.UseCellMerging = false;
-
- xlsExport.Export(this.empReport.Document, stream);
- stream.Position = 0;
- var guid = Guid.NewGuid().ToString("N");
- var reportBytes = stream.ToArray();
- Response.Clear();
- Response.ContentType = "application/force-download";
- Response.AddHeader("content-disposition", $"attachment; filename=empreport-{guid}.xls");
- Response.BinaryWrite(reportBytes);
- Response.End();
- }
- }
复制代码
导出的excel 截图
我不想字段自动换行,应该如何设置呢?
|