Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Export to Excel, ali....

[es] :: Pascal / Delphi / Kylix :: Export to Excel, ali....

[ Pregleda: 4582 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

tamnicar
sremska mitrovica

Član broj: 54010
Poruke: 67
195.252.85.*



Profil

icon Export to Excel, ali....03.05.2005. u 15:06 - pre 230 meseci
Ne nije problem sa exportom, to je uradjeno :)
problem je da li neko zna kako se, u novonastaloj workbook, boje celije, ili postavlja grid na aktivne celije ili postavlja sirina kolona i redova??
 
Odgovor na temu

reiser

Član broj: 7895
Poruke: 2314



+102 Profil

icon Re: Export to Excel, ali....03.05.2005. u 19:26 - pre 230 meseci
Probaj da nadjes na netu OfficePartner komponentu, firma TurboPower.
 
Odgovor na temu

IgLo
Igor Lovric
Sremski Karlovci

Član broj: 19524
Poruke: 129
*.neobee.net.

Sajt: www.unicornsoft.net


Profil

icon Re: Export to Excel, ali....04.05.2005. u 11:25 - pre 230 meseci
Predpostavljam da si radio komunikaciju preko OLE-a da bi uradio export. Da ne bi sada pisao novi kod, evo ti je jedna procedura koju sam koristo u nekom katalogu koji sam pravio. Jedino sto nemas u proceduri od ovoga sto si pitao je postavljanje grid-a, to nisam znao da uradim... ako neko zna neka doda, i mene interesuje. Nisam 100% siguran, ali mislim da za ovo treva dodati ComObj u Uses.

Code:

procedure TMainForm.img_ExportXLSImageClick(Sender: TObject);
Const
  xlWBATWorksheet = -4167;

Var
//  ClassID: TCLSID;

  XLApp,
  Sheet,
  Range : Variant;

  X,
  Y,
  Z,
  Temp : Integer;

  Zanrovi : TStringList;

  Function RemoveSpaces (S : String) : String;

  Begin
    While Pos (' ', S) > 0 Do
      Delete (S, Pos (' ', S), 1);
    If S = '' Then S := ' ';
    Result := S;
  End;

begin
  Try
    XLApp:= CreateOleObject('Excel.Application');
  Except
    MessageDlg('This option requires Microsoft excel to be installed.'+#13+#10+'Install Microsoft Excel and try again.', mtError, [mbOK], 0);
    Exit;
  End;

  With SaveDialog Do
    Begin
      Filter := 'Microsoft Excel Files (*.xls)|*.xls';
      FileName := XlsFileName;
      DefaultExt := 'xls';
      Title := 'Choice Excel file to export list to'
    End;

  If SaveDialog.Execute Then
    Begin
      If QuestionForm.Execute('Eksportovanje po zanru?', '') = mrYES Then
        Begin
          Zanrovi := TStringList.Create;
          Zanrovi.Sorted := True;
          For x := 0 To MovieList.Items.Count -1 Do
            If Not Zanrovi.Find(RemoveSpaces (UpperCase (MovieList.items [x].Subitems [1])), Temp) Then
              Zanrovi.Add(RemoveSpaces (UpperCase (MovieList.items [x].Subitems [1])));

          XLApp.Visible := True;
          XLApp.Workbooks.Add(xlWBatWorkSheet);
          XLApp.Workbooks[1].Sheets.Add(,,Zanrovi.Count - 1,xlWBatWorkSheet);
          For X := Zanrovi.Count - 1 DownTo 0 Do
            Begin
              XLApp.Workbooks[1].Sheets[x + 1].Name := Zanrovi [x];
              Sheet := XLApp.Workbooks[1].Sheets [x + 1];

              Range := Sheet.Columns;
              Range.Columns[1].ColumnWidth := 5;
              Range.Columns[2].ColumnWidth := 32;
              Range.Columns[3].ColumnWidth := 22;
              Range.Columns[3].ColumnWidth := 22;

              Range := Sheet.Range['A1:D1'];
              Range.Columns.Interior.ColorIndex := 49;
              Range.Columns.Font.ColorIndex := 27;
              Range.Columns.Font.Bold := True;

              Sheet.Cells[1, 1] := 'Sifra';
              Sheet.Cells[1, 2] := 'Naziv';
              Sheet.Cells[1, 3] := 'Glumci';
              Sheet.Cells[1, 4] := 'Napomena';

              Z := 0;
              For Y := 0 To MovieList.Items.Count - 1 Do
                If RemoveSpaces (UpperCase (MovieList.items [y].Subitems [1])) = Zanrovi [x] Then
                  Begin
                    Sheet.Cells [z + 2, 1] := MovieList.Items [y].Caption;
                    Sheet.Cells [z + 2, 2] := MovieList.Items [y].SubItems [0];
                    Sheet.Cells [z + 2, 3] := MovieList.Items [y].SubItems [2];
                    Sheet.Cells [z + 2, 4] := MovieList.Items [y].SubItems [3];
                    Inc (z);
                  End;

            End;
        End
      Else
        Begin
          XLApp.Visible := True;
          XLApp.Workbooks.Add(xlWBatWorkSheet);
          XLApp.Workbooks[1].WorkSheets[1].Name := 'MovieCatalog';
          Sheet := XLApp.Workbooks[1].WorkSheets['MovieCatalog'];

          Range := XLApp.Workbooks[1].WorkSheets['MovieCatalog'].Columns;
          Range.Columns[1].ColumnWidth := 5;
          Range.Columns[2].ColumnWidth := 22;
          Range.Columns[3].ColumnWidth := 12;
          Range.Columns[4].ColumnWidth := 22;
          Range.Columns[5].ColumnWidth := 22;

          Range := XLApp.Workbooks[1].WorkSheets['MovieCatalog'].Range['A1:E1'];
          Range.Columns.Interior.ColorIndex := 49;
          Range.Columns.Font.ColorIndex := 27;
          Range.Columns.Font.Bold := True;

          Sheet.Cells[1, 1] := 'Sifra';
          Sheet.Cells[1, 2] := 'Naziv';
          Sheet.Cells[1, 3] := 'Zanr';
          Sheet.Cells[1, 4] := 'Glumci';
          Sheet.Cells[1, 5] := 'Napomena';

          For X := 0 To MovieList.Items.Count - 1 Do
            Begin
              Sheet.Cells [x + 2, 1] := MovieList.Items [x].Caption;
              Sheet.Cells [x + 2, 2] := MovieList.Items [x].SubItems [0];
              Sheet.Cells [x + 2, 3] := MovieList.Items [x].SubItems [1];
              Sheet.Cells [x + 2, 4] := MovieList.Items [x].SubItems [2];
              Sheet.Cells [x + 2, 5] := MovieList.Items [x].SubItems [3];
            End;
        End;
      XLApp.Workbooks[1].SaveAs(SaveDialog.FileName);
    End;
  XLApp.Quit;
end { Export XLS file }; 
 
Odgovor na temu

tamnicar
sremska mitrovica

Član broj: 54010
Poruke: 67
195.252.85.*



Profil

icon Re: Export to Excel, ali....04.05.2005. u 11:35 - pre 230 meseci
@igLo
to je to, radi... poz :)
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Export to Excel, ali....

[ Pregleda: 4582 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.