在 Calc 中使用键盘移动行

dot*_*hen 8 keyboard openoffice-calc openoffice libreoffice libreoffice-calc

如何使用键盘将一行移动到不同的位置?我找到了这个鼠标指南,但由于残疾,我在使用鼠标时遇到了麻烦。

请注意,我不打算“手动排序”,并且使用额外的“排序序号”列不是可行的解决方法。不过,我知道 Calc 出色的排序能力。

小智 14

在 Open Office Calc 中移动一行:

  1. 选择要移动的行的 A 列中的单元格。
  2. 按 Shift-Space 突出显示整行。
  3. 按住ALT键。
  4. 将行(出现粗黑线)向上或向下拖动到所需位置。
  5. 如果您的工作看起来正确,请单击工具栏中的“保存”图标。
  6. 否则,ALT-Z撤消。

如果要覆盖和销毁目标位置,请不要按住 ALT 键。只需单击突出显示的行并拖动到它的新位置。目标位置的数据将被销毁并替换为正在移动的行的数据。

  • 听起来不错,但第 4 步涉及鼠标 - 而 OP 尝试仅使用键盘移动行。 (4认同)
  • 也适用于 LO Calc。必须交换第 3 步和第 4 步:开始拖动,然后在将行放置在新位置之前按住 ALT。 (2认同)

toh*_*ohu 7

我不确定是否有办法使用键盘“移动”行,但是使用 c&p 和使用键盘插入/删除行应该提供相同的功能:

  • 导航到要移动的行的第一个(最左边)单元格;
  • 点击SHIFT+SPACE选择整行;
  • 点击CTRL+C复制行;
  • 点击CTRL+-删除当前行;
  • 导航到目标行;
  • 点击ALT+I打开Insert菜单;
  • 点击R插入新行(当前行将向下移动);
  • 点击CTRL+V将该行粘贴到新位置。

由于剪切和粘贴操作有时很烦人,您可以创建一个简单的宏来剪切单元格,然后再创建一个来粘贴它们,将现有内容向下移动。

这是一个非常简单的代码来“移动”选定的单元格:

Option Explicit

Sub CopyAndCut
    ' ---------------------------------------------------------
    ' define variables
    Dim document   as object
    Dim dispatcher as Object
    Dim oSelections As Object
    ' ---------------------------------------------------------
    ' get access to the document and selections (if any)
    document    = ThisComponent.CurrentController.Frame
    oSelections = ThisComponent.getCurrentSelection()
    If IsNull(oSelections) Then Exit Sub        
    ' ---------------------------------------------------------
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
    dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
    ' -------------------------------------------------------------
    ' Check the width of the selection - if 1024 columns, we assume
    ' the complete row was selected and should get deleted
    If 1024 = oSelections.Columns.getCount() Then
        dispatcher.executeDispatch(document, ".uno:DeleteRows", "", 0, Array())
    End If
End Sub

Sub InsertWithMoveDown
    ' ---------------------------------------------------------
    ' define variables
    Dim document   as object
    Dim dispatcher as object
    ' ---------------------------------------------------------
    ' get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    ' ---------------------------------------------------------
    ' Paste contents with "Move Down" option
    Dim args1(5) as New com.sun.star.beans.PropertyValue
    args1(0).Name = "Flags"
    args1(0).Value = "A"
    args1(1).Name = "FormulaCommand"
    args1(1).Value = 0
    args1(2).Name = "SkipEmptyCells"
    args1(2).Value = false
    args1(3).Name = "Transpose"
    args1(3).Value = false
    args1(4).Name = "AsLink"
    args1(4).Value = false
    args1(5).Name = "MoveMode"
    args1(5).Value = 0
    dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args1())
End Sub

Sub InsertWithMoveRight
    ' ---------------------------------------------------------
    ' define variables
    Dim document   as object
    Dim dispatcher as object
    ' ---------------------------------------------------------
    ' get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    ' ---------------------------------------------------------
    ' Paste contents with "Move Right" option
    Dim args1(5) as New com.sun.star.beans.PropertyValue
    args1(0).Name = "Flags"
    args1(0).Value = "A"
    args1(1).Name = "FormulaCommand"
    args1(1).Value = 0
    args1(2).Name = "SkipEmptyCells"
    args1(2).Value = false
    args1(3).Name = "Transpose"
    args1(3).Value = false
    args1(4).Name = "AsLink"
    args1(4).Value = false
    args1(5).Name = "MoveMode"
    args1(5).Value = 1
    dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args1())
End Sub
Run Code Online (Sandbox Code Playgroud)

复制代码到你的用户库,只是分配后CopyAndCut到,例如,Alt+ CInsertWithMoveDown以便例如,Alt+ V,及 InsertWithMoveRight到,例如,Alt+ R(所有这些快捷键默认为空)。

现在,您可以使用鼠标或键盘选择单元格或行,使用Alt+剪切它们C,移动到目标单元格,然后使用Alt+VAlt+粘贴它们R

  • 如果您必须移动超过 1 行,这会变得非常烦人。 (2认同)
  • 尝试将 3 行从第 1 行移动到第 101 行(因此当前位置和新位置足够远,拖放很笨拙)。当您需要创建空行以粘贴您复制的行,然后返回到第 1 行删除它们时,您会发现它是多么烦人(因为在空白行后面切割叶子)。 (2认同)