1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Creating excel file without OLE

Discussion in 'Delphi Programming' started by AdminDF, Feb 21, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Code:
    const
      CXlsBof: array[0..5] of Word = ($809, 8, 00, $10, 0, 0);
      CXlsEof: array[0..1] of Word = ($0A, 00);
      CXlsLabel: array[0..5] of Word = ($204, 0, 0, 0, 0, 0);
      CXlsNumber: array[0..4] of Word = ($203, 14, 0, 0, 0);
      CXlsRk: array[0..4] of Word = ($27E, 10, 0, 0, 0);
    
    procedure XlsBeginStream(XlsStream: TStream; const BuildNumber: Word);
    begin
      CXlsBof[4] := BuildNumber;
      XlsStream.WriteBuffer(CXlsBof, SizeOf(CXlsBof));
    end;
    
    procedure XlsEndStream(XlsStream: TStream);
    begin
      XlsStream.WriteBuffer(CXlsEof, SizeOf(CXlsEof));
    end;
    
    procedure XlsWriteCellRk(XlsStream: TStream; const ACol, ARow: Word; const AValue: Integer);
    var
      V: Integer;
    begin
      CXlsRk[2] := ARow;
      CXlsRk[3] := ACol;
      XlsStream.WriteBuffer(CXlsRk, SizeOf(CXlsRk));
      V := (AValue shl 2) or 2;
      XlsStream.WriteBuffer(V, 4);
    end;
    
    procedure XlsWriteCellNumber(XlsStream: TStream; const ACol, ARow: Word; const AValue: Double);
    begin
      CXlsNumber[2] := ARow;
      CXlsNumber[3] := ACol;
      XlsStream.WriteBuffer(CXlsNumber, SizeOf(CXlsNumber));
      XlsStream.WriteBuffer(AValue, 8);
    end;
    
    procedure XlsWriteCellLabel(XlsStream: TStream; const ACol, ARow: Word; const AValue: string);
    var
      L: Word;    
    begin
      L := Length(AValue);
      CXlsLabel[1] := 8 + L;
      CXlsLabel[2] := ARow;
      CXlsLabel[3] := ACol;
      CXlsLabel[5] := L;
      XlsStream.WriteBuffer(CXlsLabel, SizeOf(CXlsLabel));
      XlsStream.WriteBuffer(Pointer(AValue)^, L);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      FStream: TFileStream;
      I, J: Integer;
    begin
      FStream := TFileStream.Create('J:\e.xls', fmCreate);
      try
        XlsBeginStream(FStream, 0);
        for I := 0 to 99 do
          for J := 0 to 99 do
          begin
            XlsWriteCellNumber(FStream, I, J, 34.34);
           // XlsWriteCellRk(FStream, I, J, 3434);
           // XlsWriteCellLabel(FStream, I, J, Format('Cell: %d,%d', [I, J]));
          end;
        XlsEndStream(FStream);
      finally
        FStream.Free;
      end;
    end;
     
  2. darioosh2040
    Online

    darioosh2040 Guest

    thank you
     
  3. ana21675
    Offline

    ana21675 DF Member

    great tip
     
  4. aarmada
    Online

    aarmada Guest

    RE:

    cool script
     
  5. sandro.giusto
    Offline

    sandro.giusto DF Member

    RE:

    Thank you!

    Bye, Sandro
     
  6. 2keda
    Online

    2keda Guest

    thank you, i will try it
     
  7. atlantis_club
    Offline

    atlantis_club DF Junior

  8. karim
    Online

    karim Guest

    Great, thank you :D
     

Share This Page