H
hfghfghfg
Unregistered / Unconfirmed
GUEST, unregistred user!
rm报表的web发布
//使用webSoapApplication
procedure TWebModule_rpt.WebModule_rptWebActionItem_reportAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
RPTID: string;
begin
。。。。。。。。。。
Response.Content := RMReport1.ExportToString(RMHTMExport1);
Response.ContentType := 'text/html';
end;
//修改了TRMReport
//unit RM_class;
var
ExportStream: TStream;
function TRMReport.ExportToString(Filter: TRmExportFilter):string;
var
s: string;
Flag, NeedConnect: Boolean;
begin
DocMode := dmPrinting;
FCurrentFilter := Filter;
FCurrentFilter.FileName := FileName;
if (Preview <> nil) and (EMFPages.Count = 0) then
begin
Preview.Disconnect;
NeedConnect := True;
end
else
NeedConnect := False;
Flag := True;
if Assigned(FCurrentFilter.OnBeforeExport) then
FCurrentFilter.OnBeforeExport(FCurrentFilter.FileName, Flag);
if Flag {and (FCurrentFilter.ShowModal = mrOk) }then
begin
ExportStream := TStringStream.Create('');
FCurrentFilter.Stream := ExportStream;
FCurrentFilter.OnBeginDoc;
CurReport := Self;
MasterReport := Self;
SavedAllPages := EMFPages.Count;
if FShowProgress then
begin
with RMProgressForm do
begin
s := RMLoadStr(SReportPreparing);
if Title = '' then
Caption := s
else
Caption := s + ' - ' + Title;
FirstCaption := RMLoadStr(SPagePreparing);
Label1.Caption := FirstCaption + ' 1';
OnBeforeModal := ExportBeforeModal;
Show_Modal(Self);
end;
end
else
ExportBeforeModal(Self);
result := TStringStream(ExportStream).DataString;
ExportStream.Free;
if Assigned(FCurrentFilter.OnAfterExport) then
FCurrentFilter.OnAfterExport(FCurrentFilter.FileName);
end;
if NeedConnect then
Preview.Connect(Self);
FCurrentFilter := nil;
end;
//图片的处理unit RM_e_htm;
TGetGraphicEvent = procedure(Sender: TRMMainExportFilter; AViewName: string;
var FileName: string) of object;
if ExportImages then
begin
// liFlag := (DataRec^.ViewClassName = TRMMemoView.ClassName) or (DataRec^.ViewClassName = TRMCalcMemoView.ClassName);
// if (not liFlag or DataRec^.VerticalText) and (DataRec^.ViewClassName <> TRMLineView.ClassName) then
// begin
// SetReuseImageIndex(DataRec^.ViewName, DataRec^.ViewIndex);
// if (ReuseImageIndex <> -1) and (ReuseImageIndex < FImgFileNames.Count) then
// begin
// AFileName := FImgFileNames[ReuseImageIndex];
// K := ReuseImageIndex;
// end
// else
// begin
// AFileName := FImageCreateDir + RMMakeImgFileName(ExtractFileName(FileName), 'bmp', ImgFileCount + 1);
// AFileName := SaveBitmapAs(DataRec^.Bitmap,
// ExportImageFormat{$IFDEF JPEG}, JPEGQuality{$ENDIF}, ChangeFileExt(AFileName, ''));
// K := FImgFileNames.AddObject(AFileName, TObject(Datarec^.ViewIndex));
// end;
// AFileName := FImageEncodeDir + ExtractFileName(AFileName);
// DataRec^.Bitmap.Free;
// if Assigned(FAfterSaveGraphic) then
// FAfterSaveGraphic(Self, DataRec^.ViewName, K);
if Assigned(FGetGraphicEvent) then
FGetGraphicEvent(Self, DataRec^.ViewName, AFileName);
if AFileName <> '' then
AImageSource := '<IMG SRC="' + AFileName + '" ALT="' + FAltText + '" width="' + inttostr(DataRec^.Bitmap.Width)+ '" height="' +inttostr(DataRec^.Bitmap.Height)+'">';
// end;
end;
procedure TWebModule_rpt.getG(Sender: TRMMainExportFilter;
AViewName: string; var FileName: string);
var
str: string;
idx, w, h: integer;
begin
if RMReport1.FindObject(AViewName) is TRMPictureView then
begin
with TRMPictureView(RMReport1.FindObject(AViewName)) do
begin
str := trim(Memo.Text);
w := Prop['width'];
h := Prop['height'];
end;
if checkstrtoint(str) then
idx := strtoint(str) - 1
else
idx := 0;
FileName := format('image?FileName=%s&IDX=%d', [getReportValue(DataSet_Print, '图像文件'), idx]);
end
else
FileName := '';
end;
procedure TWebModule_rpt.WebModule_rptWebActionItem_imageAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
FileName: string;
Jpg: TJPEGImage;
s: TMemoryStream;
Bmp: TBitmap;
idx: integer;
MyImg: TDicomImage;
begin
S := TMemoryStream.Create;
Jpg := TJPEGImage.Create;
Bmp := TBitmap.Create;
Bmp.Width:=128;
bmp.Height:=128;
。。。。。。。。。。。。。。。。。。。。。。。。。。。
Jpg.Assign(Bmp);
jpg.SaveToStream(s);
Response.ContentType := 'image/jpeg';
s.Position := 0;
Response.ContentStream := s;
freeandnil(Jpg);
freeandnil(Bmp);
end;
以上代码
没有问题
已经在用了
只是贴给大家
//使用webSoapApplication
procedure TWebModule_rpt.WebModule_rptWebActionItem_reportAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
RPTID: string;
begin
。。。。。。。。。。
Response.Content := RMReport1.ExportToString(RMHTMExport1);
Response.ContentType := 'text/html';
end;
//修改了TRMReport
//unit RM_class;
var
ExportStream: TStream;
function TRMReport.ExportToString(Filter: TRmExportFilter):string;
var
s: string;
Flag, NeedConnect: Boolean;
begin
DocMode := dmPrinting;
FCurrentFilter := Filter;
FCurrentFilter.FileName := FileName;
if (Preview <> nil) and (EMFPages.Count = 0) then
begin
Preview.Disconnect;
NeedConnect := True;
end
else
NeedConnect := False;
Flag := True;
if Assigned(FCurrentFilter.OnBeforeExport) then
FCurrentFilter.OnBeforeExport(FCurrentFilter.FileName, Flag);
if Flag {and (FCurrentFilter.ShowModal = mrOk) }then
begin
ExportStream := TStringStream.Create('');
FCurrentFilter.Stream := ExportStream;
FCurrentFilter.OnBeginDoc;
CurReport := Self;
MasterReport := Self;
SavedAllPages := EMFPages.Count;
if FShowProgress then
begin
with RMProgressForm do
begin
s := RMLoadStr(SReportPreparing);
if Title = '' then
Caption := s
else
Caption := s + ' - ' + Title;
FirstCaption := RMLoadStr(SPagePreparing);
Label1.Caption := FirstCaption + ' 1';
OnBeforeModal := ExportBeforeModal;
Show_Modal(Self);
end;
end
else
ExportBeforeModal(Self);
result := TStringStream(ExportStream).DataString;
ExportStream.Free;
if Assigned(FCurrentFilter.OnAfterExport) then
FCurrentFilter.OnAfterExport(FCurrentFilter.FileName);
end;
if NeedConnect then
Preview.Connect(Self);
FCurrentFilter := nil;
end;
//图片的处理unit RM_e_htm;
TGetGraphicEvent = procedure(Sender: TRMMainExportFilter; AViewName: string;
var FileName: string) of object;
if ExportImages then
begin
// liFlag := (DataRec^.ViewClassName = TRMMemoView.ClassName) or (DataRec^.ViewClassName = TRMCalcMemoView.ClassName);
// if (not liFlag or DataRec^.VerticalText) and (DataRec^.ViewClassName <> TRMLineView.ClassName) then
// begin
// SetReuseImageIndex(DataRec^.ViewName, DataRec^.ViewIndex);
// if (ReuseImageIndex <> -1) and (ReuseImageIndex < FImgFileNames.Count) then
// begin
// AFileName := FImgFileNames[ReuseImageIndex];
// K := ReuseImageIndex;
// end
// else
// begin
// AFileName := FImageCreateDir + RMMakeImgFileName(ExtractFileName(FileName), 'bmp', ImgFileCount + 1);
// AFileName := SaveBitmapAs(DataRec^.Bitmap,
// ExportImageFormat{$IFDEF JPEG}, JPEGQuality{$ENDIF}, ChangeFileExt(AFileName, ''));
// K := FImgFileNames.AddObject(AFileName, TObject(Datarec^.ViewIndex));
// end;
// AFileName := FImageEncodeDir + ExtractFileName(AFileName);
// DataRec^.Bitmap.Free;
// if Assigned(FAfterSaveGraphic) then
// FAfterSaveGraphic(Self, DataRec^.ViewName, K);
if Assigned(FGetGraphicEvent) then
FGetGraphicEvent(Self, DataRec^.ViewName, AFileName);
if AFileName <> '' then
AImageSource := '<IMG SRC="' + AFileName + '" ALT="' + FAltText + '" width="' + inttostr(DataRec^.Bitmap.Width)+ '" height="' +inttostr(DataRec^.Bitmap.Height)+'">';
// end;
end;
procedure TWebModule_rpt.getG(Sender: TRMMainExportFilter;
AViewName: string; var FileName: string);
var
str: string;
idx, w, h: integer;
begin
if RMReport1.FindObject(AViewName) is TRMPictureView then
begin
with TRMPictureView(RMReport1.FindObject(AViewName)) do
begin
str := trim(Memo.Text);
w := Prop['width'];
h := Prop['height'];
end;
if checkstrtoint(str) then
idx := strtoint(str) - 1
else
idx := 0;
FileName := format('image?FileName=%s&IDX=%d', [getReportValue(DataSet_Print, '图像文件'), idx]);
end
else
FileName := '';
end;
procedure TWebModule_rpt.WebModule_rptWebActionItem_imageAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
FileName: string;
Jpg: TJPEGImage;
s: TMemoryStream;
Bmp: TBitmap;
idx: integer;
MyImg: TDicomImage;
begin
S := TMemoryStream.Create;
Jpg := TJPEGImage.Create;
Bmp := TBitmap.Create;
Bmp.Width:=128;
bmp.Height:=128;
。。。。。。。。。。。。。。。。。。。。。。。。。。。
Jpg.Assign(Bmp);
jpg.SaveToStream(s);
Response.ContentType := 'image/jpeg';
s.Position := 0;
Response.ContentStream := s;
freeandnil(Jpg);
freeandnil(Bmp);
end;
以上代码
没有问题
已经在用了
只是贴给大家