原来Remobjects是这么一个好东东,我发现的太迟了,前几天发现以后,爱不惜手,夸数据库,夸语言(.NET和Delphi),夸平台(支持mono,FPC),我不明白banland当初为什么不买下它。
言归正传:
服务器端:用delphi+Remobjects
打开Remobjects自带的例子:/Program Files/RemObjects Software/Data Abstract for Delphi/Samples/Report Builder/ReportBuilderServer.dproj (只是要服务器端)编辑一下下面的代码。
function TDARBService.DA_GenReport(const ReportName: string; const DatasetName: string): Binary;
var
ds: IDADataset;
s: TMemoryStream;
begin
s := TMemoryStream.Create;
result := Binary.Create;
try
Report.DataPipeline := ppReport;
Report.Template.FileName := ReportBuilder_ServerMainForm.AppPath + ReportName;
Report.Template.LoadFromFile;
Report.Template.Load;
ds := DASchema.NewDataset(fConnection, DatasetName);
BinDataStreamer.WriteDataset(s, ds, [woRows, woSchema], -1);
BinDataStreamer.ReadDataset(s, dtReport, TRUE, '', TRUE, TRUE);//****修改这里
Report.AllowPrintToFile:=true;
Report.DeviceType := 'PDFFile';
Report.TextFileName := ReportBuilder_ServerMainForm.AppPath + 'ServerArchive.pdf';//****修改这里
Report.Print;
result.LoadFromFile(ReportBuilder_ServerMainForm.AppPath + 'ServerArchive.pdf');
finally
s.Free;
end;
//result.LoadFromFile('c:/TEST.txt');end;
运行它。。。再开始下一步
客户端:
用VS2008 新建一个网站:
在解决方案资源管理器--》你新建的网站方案上单击右键--》添加web引用--在弹出的对话框中URL:
填入:http://localhost:8099/soap?service=DARBService
web引用名改为RBSERVER在点击“添加引用"
在主窗体中添加一个按钮。类似的加入一些代码:
using RBserver;
using System.IO;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
protected void Button1_Click(object sender, EventArgs e)
{
RBserver.DARBService myServer=new RBserver.DARBService();
byte[] byt = myServer.DA_GenReport("Report1.rtm","Customers");
MemoryStream ms = new MemoryStream(byt, true);
ms.Read(byt, 0, Convert.ToInt32(ms.Length));
StreamWriter pPDF = new StreamWriter("C://Documents and Settings//admin//My Documents//Visual Studio 2008//WebSites//WebSite3//myPDFttt.pdf");
ms.WriteTo(pPDF.BaseStream);
ms.Close();
pPDF.Close();
Response.Redirect("http://localhost:1781/WebSite3/myPDFttt.pdf");//
}编译一下。打开。呵呵可以了吧。看来Report Builder的server版是不会有人买了!。