[Solved] Copy Sheet to another sheet
[Solved] Copy Sheet to another sheet
Hello,
In OpenOffice Calc, I need to copy all the data present from one sheet to another sheet in the same document using Delphi.
Say For Example: In sheet1, I have loaded a template and now i try to copy the same template to sheet2.
Is there any way that i can copy the data from one sheet to another?
In OpenOffice Calc, I need to copy all the data present from one sheet to another sheet in the same document using Delphi.
Say For Example: In sheet1, I have loaded a template and now i try to copy the same template to sheet2.
Is there any way that i can copy the data from one sheet to another?
Last edited by Rosinha on Mon Feb 23, 2015 6:51 am, edited 3 times in total.
OpenOffice 4.0.1 on Windows XP
Re: Copy Sheet to another sheet
Here is an example in Basic of copying the used area of Sheet 1 to Sheet2.
Alternatively, you could just copy the sheet
Code: Select all
oSheets = ThisComponent.Sheets
oSheet1 = oSheets.getByName("Sheet1")
oSheet2 = oSheets.getByName("Sheet2")
oCurs = oSheet1.createCursor()
oCurs.gotoStart()
oCurs.gotoEndOfUsedArea(True)
oRangeAddr = oCurs.RangeAddress
oTrgCell = oSheet2.getCellrangeByName("A1")
oCellAddr = oTrgCell.CellAddress
oSheet1.copyRange(oCellAddr, oRangeAddr)Code: Select all
oSheets = ThisComponent.Sheets
oSheets.copyByName("Sheet1", "NewSheet", 1) 'put the sheet in position 1, which is second from the leftOpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Copy Sheet to another sheet
Sounds to me that all you need to do is click on the column/row intersection (upper left corner) of the sheet to copy then do an edit > copy and then open the second sheet and do an and edit > paste special. The paste special will allow you to keep all of the first sheet's formatting.
Hope this helps.
Hope this helps.
Open Office 4.1.13 ~on Mac OS 12.6
Re: [Solved] Copy Sheet to another sheet
When using oSheets.copyByName("Sheet1", "NewSheet", 1) on windows 7/ windows 8 we get an error message " com.sun.star.uno.RuntimeException".
Are there any other alternatives for "copyByName" command?
Are there any other alternatives for "copyByName" command?
OpenOffice 4.0.1 on Windows XP
Re: [Solved] Copy Sheet to another sheet
Of course. This happens when there already is a sheet named "NewSheet".Rosinha wrote:When using oSheets.copyByName("Sheet1", "NewSheet", 1) on windows 7/ windows 8 we get an error message " com.sun.star.uno.RuntimeException".
Are there any other alternatives for "copyByName" command?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: [Solved] Copy Sheet to another sheet
Villeroy wrote:Of course. This happens when there already is a sheet named "NewSheet".Rosinha wrote:When using oSheets.copyByName("Sheet1", "NewSheet", 1) on windows 7/ windows 8 we get an error message " com.sun.star.uno.RuntimeException".
Are there any other alternatives for "copyByName" command?
I am changing the "NewSheet" name everytime when i try to copy the sheet.In the above post i have mentioned for example purpose.
OpenOffice 4.0.1 on Windows XP
Re: [Solved] Copy Sheet to another sheet
The macro simply works if there is a "Sheet1" but not any "NewSheet" and if the document is not protected.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: [Solved] Copy Sheet to another sheet
Does CopyByName command supports on Windows 7 and windows 8?
OpenOffice 4.0.1 on Windows XP
Re: [Solved] Copy Sheet to another sheet
All of the macro functions should still work on Windows 7 and 8. CopyByName certainly works on Windows 7.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.