C#中将水晶报表数据导出为Excel的问题
我用如事代码进行导出:
ReportDocument ReportDoc;
TableLogOnInfo logOnInfo;
DiskFileDestinationOptions FileOPS;
ExportOptions ExOPS;
public bool ExportToExcel(object ReportDataSource, string ExcelFileName)
{
try
{
ReportDoc = new ReportDocument();
logOnInfo = new TableLogOnInfo();
FileOPS = new DiskFileDestinationOptions();
//dycb.Load(ReportFile);
dycb.SetDataSource(ReportDataSource);
FileOPS.DiskFileName = ExcelFileName;
ExOPS = dycb.ExportOptions;
ExOPS.DestinationOptions = FileOPS;
ExOPS.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
ExOPS.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.ExcelRecord;
dycb.Export();
System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
Response.ClearContent();
Response.ClearHeaders();
//Response.ContentType = contentType;
//Response.WriteFile(ExcelFileName);
Response.Flush();
Response.Close();
return true;
}
catch
{
return false;
}
}
可以正常导出的,但是导出的宽度是Excel的原始宽度。请问要怎么样在导出时候更改宽度呢?
--------------------编程问答-------------------- 烦请大家帮我看看哦,能导出来,但就是宽度控制不了啊 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 我也导出过,因为他们的宽度计量单位不同所以导致导出结果不同 --------------------编程问答--------------------
那要怎么办呢? --------------------编程问答--------------------
ExportFormatType.ExcelRecord是只导出数据,不带格式的,所以是默认宽度
导出时应该用ExportFormatType.Excel格式才会按照设计时的格子宽度导出,但是这样导出又是没有格线的 --------------------编程问答-------------------- 那有没有两全其美的办法? --------------------编程问答-------------------- --------------------编程问答-------------------- 可以自己先画好线么?
我是自己先画好线的.... --------------------编程问答--------------------
是啊,有没有两全其美的办法呢?
补充:.NET技术 , C#