Recent

Author Topic: Which data types are fastest for generating a structure output to excel file?  (Read 2769 times)

noszone

  • New Member
  • *
  • Posts: 46
Can someone advise which data types are better for the subject?
For example I want to create a complex excel file with 2000+ rows of data like employees info, dates, mixed data, etc.
First my idea is to use a record type, arrays. What can be else? Thanks.

wp

  • Hero Member
  • *****
  • Posts: 11916
There are two ways to create Excel files:

#1: Use OLE (on Windows only). My impression fairly slow. https://wiki.lazarus.freepascal.org/ExcelAutomation/de (German only)

#2: Use the fpspreadsheet: https://wiki.lazarus.freepascal.org/FPSpreadsheet, cross-platform, does not support all features of Excel.

noszone

  • New Member
  • *
  • Posts: 46
Thanks, I am aware of them. My question is more about data structure(speed) from Lazarus side. For example in JS mostly used example:

Code: Javascript  [Select][+][-]
  1. const multiDataSet = [
  2.   {
  3.     columns: [
  4.       { value: "Name", widthPx: 50 }, // width in pixels
  5.       { value: "Salary", widthCh: 20 }, // width in charachters
  6.       { value: "Sex", widthPx: 60, widthCh: 20 }, // will check for width in pixels first
  7.     ],
  8.     data: [
  9.       ["Johnson", 30000, "Male"],
  10.       ["Monika", 355000, "Female"],
  11.       ["Konstantina", 20000, "Female"],
  12.       ["John", 250000, "Male"],
  13.       ["Josef", 450500, "Male"],
  14.     ],
  15.   },
  16.   {
  17.     xSteps: 1, // Will start putting cell with 1 empty cell on left most
  18.     ySteps: 5, //will put space of 5 rows,
  19.     columns: ["Name", "Department"],
  20.     data: [
  21.       ["Johnson", "Finance"],
  22.       ["Monika", "IT"],
  23.       ["Konstantina", "IT Billing"],
  24.       ["John", "HR"],
  25.       ["Josef", "Testing"],
  26.     ],
  27.   },
  28. ];

Would be effective such structures in Lazarus?

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
May be considering move it to sqlite or other equivalent db and process it inside laz, export result into an excel file would help you processong speed.  :)

wp

  • Hero Member
  • *****
  • Posts: 11916
Dedicated "hard-coded" records (type TPerson = record Name: String; Salary: Integer; Sex: Byte)) will always be faster than parsing a dynamic structure such as json, xml etc.

But I doubt that you'll notice the difference (2000 records is "nothing"). And do not forget the time to create the Excel structure. Using OLE will certainly be the speed-limiting step.

 

TinyPortal © 2005-2018