1
A
回答
1
所以這裏是一個使用Libreoffice Basic和Libreoffice API的方法。
sub ReverseColumns()
oThisWorkbook = ThisComponent
oActiveSheet = oThisWorkbook.CurrentController.ActiveSheet
oRow1 = oActiveSheet.getRows().getByIndex(0)
aFilledCellsRow1 = oRow1.queryContentCells(1+2+4+16).getRangeAddresses()
if ubound(aFilledCellsRow1) = -1 then exit sub
lLastFilledColumnRow1 = aFilledCellsRow1(ubound(aFilledCellsRow1)).EndColumn
c = 0
for i = lLastFilledColumnRow1 to 1 step -1
oCellTargetColumn = oActiveSheet.getCellByPosition(c, 0)
oRangeAddressTargetColumn = oCellTargetColumn.RangeAddress
oActiveSheet.insertCells(oRangeAddressTargetColumn, com.sun.star.sheet.CellInsertMode.COLUMNS)
oCellTargetColumn = oActiveSheet.getCellByPosition(c, 0)
oCellAddressTargetColumn = oCellTargetColumn.CellAddress
oRangeSource = oActiveSheet.Columns.getByIndex(lLastFilledColumnRow1 + 1)
oRangeAddressSource = oRangeSource.RangeAddress
oActiveSheet.moveRange(oCellAddressTargetColumn, oRangeAddressSource)
c = c + 1
next
end sub
這首先確定第1行中的最後一個填充列。然後將完成列反轉過程直到該列。
對於LibreOffice的瞭解宏從這裏開始:https://wiki.documentfoundation.org/Macros
0
如果有人在這裏想扭轉行(而不是列)的順序......我把宏代碼posted by @Axel-Richter和編輯它,所以它只是這樣做:
sub ReverseRows()
oThisWorkbook = ThisComponent
oActiveSheet = oThisWorkbook.CurrentController.ActiveSheet
oColumn1 = oActiveSheet.getColumns().getByIndex(0)
aFilledCellsColumn1 = oColumn1.queryContentCells(1+2+4+16).getRangeAddresses()
if ubound(aFilledCellsColumn1) = -1 then exit sub
lLastFilledRowColumn1 = aFilledCellsColumn1(ubound(aFilledCellsColumn1)).EndRow
c = 0
for i = lLastFilledRowColumn1 to 1 step -1
oCellTargetRow = oActiveSheet.getCellByPosition(0, c)
oRangeAddressTargetRow = oCellTargetRow.RangeAddress
oActiveSheet.insertCells(oRangeAddressTargetRow, com.sun.star.sheet.CellInsertMode.ROWS)
oCellTargetRow = oActiveSheet.getCellByPosition(0, c)
oCellAddressTargetRow = oCellTargetRow.CellAddress
oRangeSource = oActiveSheet.Rows.getByIndex(lLastFilledRowColumn1 + 1)
oRangeAddressSource = oRangeSource.RangeAddress
oActiveSheet.moveRange(oCellAddressTargetRow, oRangeAddressSource)
c = c + 1
next
end sub
相關問題
- 1. 自由報辦公室鈣和Excel呈現不同的價值
- 2. 查詢計算時間在辦公室
- 3. 如何使VBA代碼與自由報辦公室
- 4. 自由辦公室錯誤 - SSL和gmail
- 5. 沒有行限制自由辦公室
- 6. 插入HTML自由辦公室
- 7. 自由報辦公室Calc的複製和值加倍到另一列
- 8. 免費辦公室365訂閱
- 9. 反向訂購BST插入
- 10. 的Excel /自由辦公計算器遞增列有特定的值
- 11. 辦公室辦公室文件在辦公室辦公室文件2007年登錄提示只在產品
- 12. 辦公室2013
- 13. 自由職業辦公室自定義對話框表
- 14. 如何定製CSL文件,從而可以使用自由報辦公室
- 15. 辦公室interop不能在多臺計算機上工作
- 16. 開放式辦公室計算動態單元格選擇
- 17. 開放式辦公室電子表格計算
- 18. 訂購由子陣列
- 19. 在自由辦公室中用一個數字多個特定列的數字
- 20. 辦公室365 Powershell
- 21. 辦公室2013字
- 22. 在自由辦公室出口後不再有圓形圖形
- 23. 自由職業辦公室,清理範圍
- 24. 自由辦公室基地:無法更改或保存記錄
- 25. 使用CSS將CSS複製到自由辦公室
- 26. 在自由職業辦公室寫作theta
- 27. 自由職業辦公室計算號碼格式化/印度數字格式化的一百個分隔符
- 28. C#辦公室2010自動化
- 29. 自定義辦公室菜單
- 30. 辦公室JS自定義格式
這個問題是如何與編程有關的?在舊列「A」前面插入一個新的空列「A」。剪切/粘貼現在的最後一列'D'。現在將列B剪切/粘貼到現在空的列D中。刪除現在空的列'B'。 –
@AxelRichter感謝您的評論。但我認爲存在誤解。這3列僅僅是一個例子。我想爲大量的列做這個。所以剪切和粘貼不是我想要的。這應該可能通過編程。 – SirSaleh
那麼應該使用哪種編程語言? –