Recent

Author Topic: fpspreadsheet insert a row  (Read 3427 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 618
fpspreadsheet insert a row
« on: July 25, 2014, 09:32:39 pm »
Is it possible to insert a row in Excel with pfspreadheet?

And is it possible to start excel with fpspreadheet or do i have to use ole to start Excel?

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: fpspreadsheet insert a row
« Reply #1 on: July 25, 2014, 09:55:42 pm »
fpspreadsheet is independent of Excel, it has nothing to do with ole.

But of course, you can start Excel in your Lazarus program as you can run any other application (http://wiki.freepascal.org/Executing_External_Programs), and you can pass a file written by fpspreadsheet to Excel by means of a parameter. And of course, you can use ole for this purpose as well.

Currently it is not possible to insert a row in fpspreadsheet.

Hansvb

  • Hero Member
  • *****
  • Posts: 618
Re: fpspreadsheet insert a row
« Reply #2 on: July 25, 2014, 10:31:13 pm »
ok, i will use ole. Is it then possible to copy a row.
This seems to work:

Code: [Select]
ExcelApp.WorkSheets[1].Rows[18].Copy;

But how can i paste it? Paste and pasteSpecial don't work;

Hansvb

  • Hero Member
  • *****
  • Posts: 618
Re: fpspreadsheet insert a row
« Reply #3 on: July 25, 2014, 10:37:37 pm »
Found it:

Code: [Select]
ExcelApp.WorkSheets[1].Range['A1', 'A1'].EntireRow.Copy(ExcelApp.WorkSheets[1].Range['A2',
 'A2'].EntireRow); 

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: fpspreadsheet insert a row
« Reply #4 on: July 26, 2014, 07:12:54 pm »
In the recent trunk rev 3381 of fpspreadsheet, TsWorksheet has new methods InsertRow and InsertCol.

One little warning though: Since currently we do not parse formula strings, you have to be aware that cell references in formula strings after the insertion point are not corrected for the new cell addresses. This happens for xlsx and ods files. The formulas in xls files, on the other hand, are internally represented by rpn formulas which are fully updated and still valid.

 

TinyPortal © 2005-2018