⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wwexport.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                                combostr := combostr +' selected';
                             combostr := combostr +'>'+DisplayStr+wwCRLF;
                          end
                          else begin
                             combostr := combostr+'<Option Value="'+Items[j]+'"';
                             if AnsiCompareText(tempstr,Items[j])=0 then
                                combostr := combostr +' selected';
                             combostr := combostr +'>'+Items[j]+wwCRLF;
                          end;
                       end;
                       combostr := combostr + '</Select>'+wwCRLF;
                       tempstr := combostr;
                    end;
                 end
                 else begin
                    if tempstr = '' then tempstr := '&nbsp;';
                 end;
              end
              else if tempstr = '' then tempstr := '&nbsp;';
           end
           else begin
              if tempstr = '' then tempstr := '&nbsp;';
           end;

           if (AControlType = 'URL-Link') and (esoEmbedURL in self.Options) then begin
             GetURLLink(Datalink.Fields[i].asString,URLDisplay, LinkAddress);

             if AnsiCompareText(URLDisplay,LinkAddress)=0 then begin
                 //Add MailTo: tag to link string for links that are in an email format.
                 pos1:= AnsiPos('@', LinkAddress);
                 pos2:= AnsiPos('.', LinkAddress);
                 pos3:= AnsiPos('MAILTO:',AnsiUpperCase(LinkAddress));
                 if (pos1>1) and (pos2>pos1) and (pos3 <=0) then
                    LinkAddress:= 'MailTo:' + LinkAddress;

{                 pos1:= AnsiPos('HTTP:',AnsiUpperCase(LinkAddress));
                 pos3:= AnsiPos('MAILTO:',AnsiUpperCase(LinkAddress));
                 if (pos1 < 1) and (pos3 <1) then
                    LinkAddress:= 'http://' + LinkAddress;}
             end;

             tempstr := '<A href="'+LinkAddress+'">'+tempstr+'</A>';
           end;

           tempstr := ReplaceStrWithStr(tempstr,#13#10,'<BR>');
           RowStr := RowStr + '<TD NOWRAP';

           //Don't set alignment if this is a Checkbox.
           if AControlType<>'CheckBox' then
              RowStr := RowStr + ' ALIGN="'+getalignstr(DataLink.Fields[i].Alignment)+'"';

           gridFont := Grid.Canvas.Font;
           gridFont.assign(Font);
           gridBrush := Grid.Canvas.Brush;
           GridBrush.Color:=Color;

           if esoShowAlternating in self.options then begin
             if not odd(currowcount mod 2) then
                GridBrush.Color := PaintOptions.AlternatingRowColor;
           end;

           if esoDynamicColors in self.Options then
              Grid.DoCalcCellColors(DataLink.Fields[i], [], False, gridFont, gridBrush);

           if (gridfont.Name <> Font.Name) or (GridFont.Size <> Font.Size) or
              (gridfont.Color <> Font.color) then
              RowStr := RowStr + ' '+SetFontStr(GridFont);

           if GridBrush.Color <> Color then
              RowStr := RowStr + ' '+SetBkgrndColor(GridBrush.Color);

           // Conversion Factor for desired display in Twips (1440 Twips = 1 Inch)
           if OutputWidthinTwips = 0 then
              xfactor := 1.0
           else xfactor := OutputWidthinTwips/((TotalPixelCount/Screen.PixelsPerInch)*1440.0);

           if esoBestColFit in self.Options then begin
               if ((AControlType = 'RichEdit') or ((DataLink.Fields[i] is TMemoField) and (mGridShow in MemoAttributes))) then
                  RowStr := RowStr + ' WIDTH="'+inttostr(Trunc(ColWidthsPixels[i+xIndicatorOffset]))+'" SCOPE="row">'+SetFormatStyle(tempstr,gridfont)+'</TD>'+wwCRLF
               else RowStr := RowStr + ' WIDTH="0*" SCOPE="row">'+SetFormatStyle(tempstr,gridfont)+'</TD>'+wwCRLF;
           end
           else RowStr := RowStr + ' WIDTH="'+inttostr(Trunc(ColWidthsPixels[i+xIndicatorOffset]*xfactor))+'" SCOPE="row">'+SetFormatStyle(tempstr,gridfont)+'</TD>'+wwCRLF;
        end;
        RowStr := RowStr + '</TR>'+wwCRLF;
        result := RowStr;
      end;
    end;

    function WriteTextDataRow:String;
    var i:integer;
        colwidth:integer;
        RowStr:String;
    begin
      with Grid do begin
        if esoShowRecordNo in self.Options then begin
          if FDelimiter = '' then
             rowstr := Format('%*s%s',[8,AddQuotes(intToStr(curRowCount)),' '])
          else rowstr := AddQuotes(IntToStr(curRowCount))+FDelimiter;
        end
        else rowstr := '';
        for i:=0 to exportFieldList.Count-1 do begin
          if (exportFieldList[i] = 'T') then begin
            if FDelimiter = '' then begin
               colwidth :=  Columns[getdbcol(Grid,I+xIndicatorOffset)].DisplayWidth+QuotesPad;
               colwidth := wwmax(Length(Columns[getdbcol(Grid,I+xIndicatorOffset)].DisplayLabel)+QuotesPad,colwidth);
               if Datalink.Fields[i].Alignment = taLeftJustify then
                   rowstr := rowstr + Format('%-*s',[colwidth,AddQuotes(GetFieldValue(i))])
               else rowstr := rowstr + Format('%*s',[colwidth,AddQuotes(GetFieldValue(i))]);
               if i <> exportFieldList.Count-1 then rowstr := rowstr + ' ';
            end
            else begin
               rowstr := rowstr + AddQuotes(GetFieldValue(i));
               if i <> exportFieldList.Count-1 then rowstr := rowstr + FDelimiter;
            end;
          end;
        end;
        rowstr := rowstr+wwCRLF;
        result := rowstr;
      end;
    end;

    function WriteTextHeader:string;
    var rowstr:string;
        i:integer;
    begin
       with Grid do begin
         if esoShowRecordNo in self.Options then begin
            if FDelimiter = '' then rowstr := Format('%*s%s',[8,'#',' '])
            else rowstr := AddQuotes('#')+FDelimiter;
         end
         else
            rowstr := '';

         for i:= 0 to exportFieldList.count - 1 do begin
            if (exportFieldList[i] = 'T') then begin
               if FDelimiter = '' then begin
                 if Datalink.Fields[i].Alignment = taLeftJustify then
                     rowstr := rowstr + Format('%-*s',[Columns[getdbcol(Grid,I+xIndicatorOffset)].DisplayWidth+QuotesPad,
                               AddQuotes(strReplaceCharWithStr(Columns[getdbcol(Grid,i+xIndicatorOffset)].DisplayLabel,'~',' '))])
                 else rowstr := rowstr + Format('%*s',[Columns[getdbcol(Grid,I+xIndicatorOffset)].DisplayWidth+QuotesPad,
                               AddQuotes(strReplaceCharWithStr(Columns[getdbcol(Grid,i+xIndicatorOffset)].DisplayLabel,'~',' '))]);
                 if i <> exportFieldList.Count-1 then rowstr := rowstr + ' ';
               end
               else begin
                  rowstr := rowstr + AddQuotes(strReplaceCharWithStr(Columns[getdbcol(Grid,i+xIndicatorOffset)].DisplayLabel,'~',' '));
                  if i <> exportFieldList.Count-1 then rowstr := rowstr + FDelimiter;
               end
            end;
         end;
         rowstr := rowstr + wwCRLF;
         result := rowstr;
       end;
    end;

    Function getdisplaylabelforline(lbl: string;lineno:integer): string;
    var APos, curlineno: integer;
        line: string;
    begin
       APos:= 1;
       result := '';
       if lineno = 0 then exit;
       curlineno := 1;
       while True do begin
          line:= strGetToken(lbl, '~', APos);
          if curlineno = lineno then begin
             result := line;
             exit;
          end;
          if (line='') and ((APos<=0) or (APos>=length(line))) then break;
          inc(curlineno);
       end;
    end;

    function WriteSYLKHeader:string;
    var Rowstr:string;
        i,j,k,count,startcol,endcol:integer;
        groupcolcount:integer;
//        groupassigned :boolean;
        recoffset : integer;
        fonttag,formatstr:string;
        gridfont:TFont;
        gridbrush:TBrush;
        gridTitleAlignment:TAlignment;
        SYLKFormatList:TStrings;
        tempdisplaylabel:string;
        exportfieldcount:integer; // 10/01/2001 -PYW - Use current numbered exported field instead of fieldnumber
    begin
       SYLKFontList:=TStringList.Create;
       SYLKFormatList := TStringList.Create;
       //Add Grid TitleFont
       gridFont := Grid.Canvas.Font;
       gridFont.assign(TwwDBGrid(Grid).TitleFont);
       AddToSYLKFontList(gridFont,SYLKFontList);
       //Add GridFont
       gridFont := Grid.Canvas.Font;
       gridFont.assign(TwwDBGrid(Grid).Font);
       AddToSYLKFontList(gridFont,SYLKFontList);

       //Set Identifier and Program name
       rowstr := 'ID;P'+'W2W 3000'+';N;E'+wwCRLF;
       // 9/26/2001-Add general format strings for date/time/datetime and currency to header. - PYW
       SYLKFormatList.Add('General');
       count:=1;
       // 9/26/2001-Build list of unique formats and store appropriate index into list for field export.
       for i:= 0 to exportFieldList.Count-1 do begin
          case Grid.Datalink.Fields[i].datatype of
           ftDate: formatstr:='m/d/yyyy';
           ftTime: formatstr:='h:mm\ AM/PM';
           {$ifdef wwDelphi6Up}
           ftTimeStamp,
           {$endif}
           ftDateTime: formatstr:='m/d/yyyy\ h:mm\ AM/PM';
           ftCurrency: formatstr:='"'+'$'+'"'+'#,##0.00_);;[Red]\('+'"'+'$'+'"'+'#,##0.00\)';
           else
              formatstr := 'General';
          end;
          Grid.DoExportSYLKFormat(grid,Grid.Datalink.Fields[i],formatstr);
          if SYLKFormatList.IndexOf(formatstr) < 0 then begin
             SYLKFormatList.Add(formatstr);
             SYLKFormatIndex[i] := inttostr(Count);
             inc(Count);
          end
          else SYLKFormatIndex[i] := IntToStr(SYLKFormatList.IndexOf(formatstr));
       end;

       // Place formatlist into header.
       for i:=0 to SYLKFormatList.count-1 do
          rowstr := rowstr+'P;P'+SYLKFormatList[i]+wwCRLF;

       SYLKFormatList.Free;

       //Set dimensions.
       //NOTE: Don't know rowcount yet so leave blank.
       if esoShowRecordNo in self.options then
          rowstr := rowstr+'B;Y'+';X'+inttostr(exportfieldList.count+1)+wwCRLF
       else  rowstr := rowstr+'B;Y'+';X'+inttostr(exportfieldList.count)+wwCRLF;

       // 3/13/2002-PYW-Add new property to allow use of A1 reference in Excel vs R1C1.
       if UseA1SYLKReference then rowstr := rowstr+'O;L'+wwCRLF;

       //Turn off grid lines in excel.
       rowstr := rowstr+ 'F;G;M255'+wwCRLF;

       count := 0;
       recoffset := 0;
       //Fill Widths of each column
       if (esoShowRecordNo in Options) then begin
          rowstr := rowstr+'F;W1 1 10'+wwCRLF;
          recoffset := 1;
          inc(count);
       end;

       for i:= 0 to exportFieldList.Count-1 do begin
          if (exportFieldList[i] = 'T') then begin
             inc(count);
             if esoBestColFit in self.Options then
                rowstr := rowstr+'F;W'+inttostr(count)+' '+inttostr(count)+' '+inttostr(grid.DataLink.Fields[i].DisplayWidth)+wwCRLF
             else rowstr := rowstr+'F;W'+inttostr(count)+' '+inttostr(count)+' '+inttostr(Grid.Columns[getdbcol(Grid,I+grid.xIndicatorOffset)].DisplayWidth)+wwCRLF;
          end;
       end;

//       groupassigned := False;
       if esoShowHeader in Options then begin
         for j:= 0 to grid.titlelines-1 do begin
           i:=0; //Start back at the first field.
           exportfieldcount:=recoffset;
           if (esoShowRecordNo in Options) then begin
              if (j=0) then begin
                 rowstr := rowstr+'F;SLRTM0;FG0C;Y1;X1'+wwCRLF;
                 rowstr := rowstr+'C;K"#"'+wwCRLF;
              end
              else begin
                 rowstr := rowstr+'F;SLRBM0;FG0C;Y'+inttostr(j+1)+';X1'+wwCRLF;
              end;
           end;
           while i < exportFieldList.Count do begin
               if (exportFieldList[i] = 'F') then begin
                  inc(i);
                  continue;
               end;
                 //If we are on a subgroup or a nongroup title cell
                 if (j>0) or (grid.Columns[getdbcol(Grid,i+grid.xIndicatorOffset)].GroupName = '') then begin
                    if (exportFieldList[i] = 'T') then begin
                      gridFont := Grid.Canvas.Font;
                      gridFont.assign(TwwDBGrid(Grid).TitleFont);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -