DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: tkzcol
今日帖子: 4
在线用户: 1
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 aknightchen (.) ★☆☆☆☆ -
盒子活跃会员
2014/5/17 11:25:11
标题:
如何将utf8转化为utf16 (fastReport升级问题) 浏览:1791
加入我的收藏
楼主: 请教一下,旧版fastReport中.

frxMemoView是不是采用UTF8 ?(我不确信)

如何将它改为UTF16(新版好像采用这个,--我也不确信)

我想要一个函数,实现UTF8转化为UTF16.

如转化(FastReport报表文件升级)成功,将把源码与大家分享.

我想要一个函数,实现UTF8转化为UTF16.
我想要一个函数,实现UTF8转化为UTF16.

哪位兄台指点一下,万分感谢!
----------------------------------------------
...
作者:
男 aknightchen (.) ★☆☆☆☆ -
盒子活跃会员
2014/5/17 15:36:12
1楼: 算了,自已用一个笨方法.

先在D7下,从报表中,提取出文字,保存到INI中.

然后,再用XE5中写个程序, 再从INI中提出文字,重新填入报表中.


以下代码,仅用于提示新手:




procedure TForm1.Button1Click(Sender: TObject);
  procedure SaveFR3CompTxtToIni(aTmpFrxComp:TfrxComponent);
  var
    i:Integer;
    tmpFrxComp:TfrxComponent;
  begin
    for i:=0 to aTmpFrxComp.Objects.Count-1 do
    begin
      tmpFrxComp:=aTmpFrxComp.Objects[i];
      if tmpFrxComp is TfrxMemoView then
      begin
        //Memo1.Lines.Add(TfrxMemoView(tmpFrxComp).Name+' **** '+TfrxMemoView(tmpFrxComp).Text);
        这里,自已写代码...将 TfrxMemoView(tmpFrxComp).Text 保存到一个ini中,同时记录下"TfrxMemoView(tmpFrxComp).Name".

        下一步,你还要用XE写一个导入程序,和这个代码差不多,也是frxReport1.LoadFromFile,再循环,再把INI中对应的值,填进去.
      end
      else
      begin
         SaveFR3CompTxtToIni(tmpFrxComp);
      end;
    end;
  end;
begin


        frxReport1.LoadFromFile('c:\1.fr3');

        //此程序是递归循环
        SaveFR3CompTxtToIni(frxReport1);

        frxReport1.SaveToFile('c:\1.fr3');

end

这是D7中的读出frxMemoView.Text,并保存到INI中.

抛砖引玉.

有更好的方法,请告诉我.
----------------------------------------------
...
作者:
男 aknightchen (.) ★☆☆☆☆ -
盒子活跃会员
2014/5/18 14:45:50
2楼: 以下代码,有些函数要换一下.(是我个人的函数,你们改装一下就行了)


procedure TForm1.Button1Click(Sender: TObject);
var
  aIniFile:TIniFile;
  sUpGradeOKFileName:string;
  aStream:TMemoryStream;

  procedure SaveFR3CompTxtToIni(aTmpFrxComp:TfrxComponent);
  var
    i:Integer;
    tmpFrxComp:TfrxComponent;
  begin
    for i:=0 to aTmpFrxComp.Objects.Count-1 do
    begin
      tmpFrxComp:=aTmpFrxComp.Objects[i];

      if tmpFrxComp is TfrxBarcode2DView then
      begin
        aIniFile.WriteString('TfrxBarcode2DView',TfrxBarcode2DView(tmpFrxComp).Name,kBase64Encode(TfrxBarcode2DView(tmpFrxComp).Text));
      end
      else if tmpFrxComp is TfrxMemoView then
      begin
        aIniFile.WriteString('TfrxMemoView',TfrxMemoView(tmpFrxComp).Name,kBase64Encode(TfrxMemoView(tmpFrxComp).Text));
      end
      else if tmpFrxComp is TfrxDBCrossView then
      begin
        aIniFile.WriteString('TfrxDBCrossView',TfrxDBCrossView(tmpFrxComp).Name+'.CellFields.Text',kBase64Encode(TfrxDBCrossView(tmpFrxComp).CellFields.Text));
        aIniFile.WriteString('TfrxDBCrossView',TfrxDBCrossView(tmpFrxComp).Name+'.ColumnFields.Text',kBase64Encode(TfrxDBCrossView(tmpFrxComp).ColumnFields.Text));
        aIniFile.WriteString('TfrxDBCrossView',TfrxDBCrossView(tmpFrxComp).Name+'.RowFields.Text',kBase64Encode(TfrxDBCrossView(tmpFrxComp).RowFields.Text));
      end
      else
      begin
        SaveFR3CompTxtToIni(tmpFrxComp);
      end;
    end;
  end;
begin
  sUpGradeOKFileName:=sGetTmpDir+'UpGradeOK';
  DeleteFile(sUpGradeOKFileName);

  try
    ADOQuery1.Close;
    ADOQuery1.ConnectionString:='Provider=SQLOLEDB.1;Password='+Edit3.Text+';Persist Security Info=True;User ID='+Edit2.Text+';Initial Catalog='+Edit4.Text+';Data Source='+Edit1.Text+'';

    ADOQuery1.SQL.Text:='SELECT * FROM REPORTS ORDER BY ID';
    try
      ADOQuery1.Open;
    except
      ShowMessage('无法从数据库中读取旧的报表文件!'+#13
          +ADOQuery1.ConnectionString);
      Exit;
    end;

    //该程序,是放在system目录下
    with AdoQuery1 do
    begin
      First;
      while not Eof do
      begin

        aStream:=TMemoryStream.Create;
        try
          TBlobField(FieldByName('FR3_FILE')).SaveToStream(aStream);
          aStream.Position:=0;
          frxReport1.LoadFromStream(aStream);

          //此程序是递归循环
          aIniFile:=TInifile.Create(sGetTmpDir+FieldByName('ID').asString+'.ini_fr3_');
          SaveFR3CompTxtToIni(frxReport1);
          aIniFile.Free;
        finally
          aStream.Free;
        end;

        Next;
      end;
    end;

    with TStringList.Create do
    begin
      SaveToFile(sUpGradeOKFileName);
      Free;
    end;

  finally
    if ParamCount>=1 then
      Application.Terminate
    else
      ShellExecute(0,'OPEN','EXPLORER',PChar(sGetTmpDir),nil,SW_RESTORE);

  end;
end;
----------------------------------------------
...
作者:
男 aknightchen (.) ★☆☆☆☆ -
盒子活跃会员
2014/5/18 14:47:27
3楼: 注意,我对TEXT进行BASE64加密一下,防止在INI中读取异常或不完整的情况发生.
----------------------------------------------
...
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行70.3125毫秒 RSS