Creating your first document

To make use of OExport add the OExport, OExport_Vcl and OExport_VclForms (alternatively OExport and OExport_FMX if you use FireMonkey) units to the uses clause of your unit and create a TOExport object.

Furthermore do not forget to set the OExportDateFormat and OExportTimeFormat global variables.

A simple code snippet for a basic XLSX document would be:

uses
  OExport, OExport_Vcl, OExport_VclForms;

procedure CreateDocument(const aFileName: String);
var xExport: TOExport;
begin
  xExport := TOExport.Create;
  try
    with xExport.AddWorkSheet('simple types') do begin
      AddRow;
      with AddRow do begin
        AddCellString('string').SetWidth(200);
        AddCellString('my "custom" string').SetWidth(400).
          SetAlignment(taCenter).SetBorders(cbAll, ebThick, clGreen).
          SetBorder(cbBottom, ebDouble, clRed);
      end;
      with AddRow do begin
        AddCellString('integer');
        AddCellNumber(15, 0);
      end;
      with AddRow do begin
        AddCellString('float');
        AddCellNumber(15.7812, 2);
      end;
      with AddRow do begin
        AddCellString('formula');
        AddCellFormulaNumber('B3+100*B4', 2);
      end;
      with AddRow do begin
        AddCellString('date');
        AddCellDate(Now);
      end;
      AddRow;
      with AddRow do begin
        AddCellString;
        AddCellString('cell spanned over 3 columns and 2 rows').SetColSpan(3).SetRowSpan(2).
          SetVAlignment(cavCenter).SetAlignment(cahCenter).SetBorders(cbAll, ebMedium, clBlue).
          SetBGColor(clYellow);
      end;
    end;

    xExport.SaveToFileWithDialog;
  finally
    xExport.Free;
  end;
end;

initialization
  OExportDateFormat := OEXPORT_SYS_DATE;
  OExportTimeFormat := OEXPORT_SYS_TIME;
end.
Categories