Home Articles

在导出到Excel时在FarPoint中添加一些文本

Asked
Viewed 1112 times
1

我正在使用FarPoint Web Spread和一个带有文本框[T1]的面板 . 我正在使用FpSpread的SaveExcel方法将内容写入Excel .

有什么方法可以将文本框[T1]的内容写入excel .

以下是我用于导出excel的代码 -

Response.Clear();
        Response.ContentType = "application/vnd.ms-excel";
        Response.AppendHeader("Content-Disposition", "Attachment; filename=Export.xls;");
        Response.Charset = "";
        using (MemoryStream ms = new MemoryStream())
        {
          FpSpread1.ActiveSheetView.Protect = false;
          FpSpread1.SaveExcel(ms, FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
          ms.WriteTo(Response.OutputStream);
        }
        Response.End();

1 Answer

  • 1
    • 我建议创建代理FpSpread并将Orignal数据的内容复制到代理对象中 .

    • 在Proxy FPSpread中创建新列,然后让Farpoint.SaveExcel()负责导出 .

    FpSpread fpproxy = new FpSpread();
        fpproxy = OriginalFPspread;
    
        fpproxy .ActiveSheetView.AddColumns(0, 2);// add new column
    
        fpproxy .Cells[0, 1].Column.Label = "your data";
        fpproxy .Cells[0, 1].Value = "your value";
    

    添加此数据后,在fpproxy上调用SaveExcel()

Related