Jump to content

zekeriye

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by zekeriye

  1. Hi;

     

    I  was successfully to export and download a datasource content using ZEXMLSS

    Download XML file and open with excel it works very nice for me.

     

    Used Component :

    ZEXMLSS and ZColorStringGrid  from http://avemey.com/index.php?lang=en

    Turbo power tpabbrevia from http://sourceforge.net/projects/tpabbrevia/?source=dlp

    You must install a zip component and zcolorstring for exporting.

     

    I need some modification ZEXMLSS compatiblity for tpabbrevia manually during installation.

    Here is sample code which was  tested  via XE2

     

    PS : sorry for big capital. I am always using big capital writting a program.

    // Tdosyaver is uniform formname

    // RAPORHAZIRLA(XFILENAME:STRING);

     

    // Prepare data and export it using ZEXMLSS. QLIST is a datasource and opened before this proc.

    PROCEDURE TDOSYAVER.RAPORHAZIRLA(XFILENAME:STRING);
    //uses zexmlss, zeodfs, zexmlssutils, zeformula, zsspxml, zexlsx;
    var
      XMLSS: TZEXMLSS;
      i, j: integer;
      TextConverter: TAnsiToCPConverter;
      sEOL: string;
      XSAYI : INTEGER;
      XSATIR : INTEGER;
      XCOL : INTEGER;
    begin
      TextConverter := nil;
      {$IFNDEF FPC}
        {$IF CompilerVersion < 20} // < RAD Studio 2009
      TextConverter := @AnsiToUtf8;
        {$IFEND}
      {$ENDIF}

      {$IFDEF FPC}
      sEOL := LineEnding;
      {$ELSE}
      sEOL := sLineBreak;
      {$ENDIF}

      XMLSS := TZEXMLSS.Create(nil);
      try
        //There are 1 pages in this document
        XMLSS.Sheets.Count := 1;
        XMLSS.Sheets[0].Title := 'Sayfa1'; // EXCEL SHEET NAME
        //Add styles
        XMLSS.Styles.Count := 1;
        XMLSS.Styles[0].Font.Size := 10;
        XMLSS.Styles[0].Font.Name := 'Arial';

        XMLSS.Styles[0].Alignment.Horizontal := ZHCenter; // This parameters are optional and some styles options too (line backcolor, text oriantation  etc).
        XMLSS.Styles[0].Alignment.Vertical := ZVCenter;
        XMLSS.Styles[0].Alignment.WrapText := true;

       with XMLSS.Sheets[0] do begin
          //the count of rows and columns

          // ZEXMLSS must know how many contain rows and cols. You must set this properties before beginging exporting.
          RowCount := 50; //
          ColCount := 20;
          // All Field Names
          FOR XSAYI:=0 TO QLIST.FIELDS.COUNT-1 DO BEGIN
              CELL[XSAYI,1].CellStyle:=1;
              CELL[XSAYI,1].DATA:=QLIST.FIELDS[XSAYI].FIELDNAME;
          END;
          //
          XSATIR:=2; // row. First row contain field
          XCOL:=0;

          // we transfer to all records to ZEXMLSS
          WHILE NOT QLIST.EOF DO BEGIN
             FOR XCOL:=0 TO QLIST.FIELDS.COUNT-1 DO BEGIN
                CELL[XCOL,XSATIR].CellStyle:=1;
                CELL[XCOL,XSATIR].DATA:=QLIST.FIELDS[XCOL].ASSTRING;
             END;
             QLIST.NEXT;
             INC(XSATIR);
          END;

        end;
      finally
        FreeAndNil(XMLSS);
      end;
    end;
     

    procedure TDOSYAVER.BTNEXCELClick(Sender: TObject);
    VAR
       XFILENAME : STRING;
    begin
       XFILENAME:='Report.XML';
       XFILENAME:=UniServerModule.LocalCachePath+XFILENAME;
       RAPORHAZIRLA(XFILENAME);
       UniSession.sendFile(XFILENAME);

    end;

     

     

     

×
×
  • Create New...