如何在 Libreoffice 中像十字准线一样突出显示当前行和列?

Jon*_*ein 12 setup gui highlighting libreoffice-calc usability

如何在 Libreoffice 中像十字准线一样突出显示当前行和列作为眼睛的引导?

Libreoffice 中的十字线

似乎有一个2011 年的开放功能请求,还有一个针对openoffice的非常相似的问题 - 但目前我在 libreoffice 上找不到任何内容并得到支持。我怎样才能让 LibreOffice 做到这一点?

Jim*_*m K 7

Lupp 最近创建了一个示例电子表格,该电子表格使用宏来实现此行为。它发布在https://forum.openoffice.org/en/forum/viewtopic.php?t=43531#p431848

\n\n

然而,他在 AskLO 上表示:

\n\n
\n

使用“宏”来达到此目的是一种值得怀疑的方法。该解决方案仅适用于不使用硬(直接)单元格格式的工作表......实际上不推荐!

\n
\n\n

唯一好的解决方案是可以在 LibreOffice 中实现。但正如您可能在错误报告中读到的那样:

\n\n
\n

与一位经验丰富的开发人员交谈......这不是一件简单的任务。它可能永远不会被实施。

\n
\n\n

正如我在 AskLO 上回答同一问题时提到的,一个实用的解决方案是使用条件格式为奇数行或偶数行添加颜色。

\n\n

编辑

\n\n

要从头开始重现 Lupp 的示例,请首先转到“工具”->“宏”->“组织宏”->“LibreOffice Basic”。 找到.ods文件,按New创建一个新模块,并将以下代码放入模块中。

\n\n
Global focusCellAddressGl As String, columnWithFocusCellGl As Long, rowWithFocusCellGl As Long\n\nFunction focusCell(Optional pCtrl) As Object\nREM Concept by "uros", "Villeroy"\nREM Responsible for this variant: Wolfgang J\xc3\xa4ger\nREM 2017-09-28 V0\nOn Error Goto eExit\nIf IsMissing(pCtrl) Then pCtrl = ThisComponent.CurrentController\nIf  NOT pCtrl.SupportsService("com.sun.star.sheet.SpreadsheetView") Then Exit Function\n    Dim theSheet As Object, fC As Object, sheetNum As Long, sInfo As String, sInfoDelim As String \n    Dim vD, vDSplit, sInfoSplit\nvD             = pCtrl.ViewData\nvDSplit        = Split(vD, ";")\ntheSheet       = pCtrl.ActiveSheet\'s(sheetNum)\nsheetNum       = theSheet.RangeAddress.Sheet\nsInfo          = vDSplit(sheetNum + 3)\nREM For CellAddress.Row >= 8192 the "+" is used as the subdelimiter in ViewData. WHY?\nIf InStr(sInfo, "+")>0 Then \n    sInfoDelim = "+"\nElse\n    sInfoDelim = "/"\nEnd If\nsInfoSplit     = Split(sInfo, sInfoDelim)\nfC             = theSheet.GetCellByPosition(sInfoSplit(0), sInfoSplit(1))\nfocusCell      = fC\neExit:\nEnd Function \n\nFunction focusCellAddress(Optional pDummy)\nOn Error Goto eExit\nIf focusCellAddressGl="" Then onSelectionChanged(NULL)\nfocusCellAddress=focusCellAddressGl\neExit:\nEnd Function\n\nFunction columnWithFocusCell(Optional pDummy)\nOn Error Goto eExit\nIf columnWithFocuscellGl=0 Then onSelectionChanged(NULL)\ncolumnWithFocusCell=columnWithFocusCellGl\neExit:\nEnd Function\n\nFunction rowWithFocusCell(Optional pDummy)\nOn Error Goto eExit\nIf rowWithFocuscellGl=0 Then onSelectionChanged(NULL)\nrowWithFocusCell=rowWithFocusCellGl\neExit:\nEnd Function\n\nSub onSelectionChanged(pEvent)\nOn Error Goto eExit\ntFC=focusCell()\nfocusCellAddressGl=Split(tFC.AbsoluteName,".")(1)\nWith tFC.CellAddress\ncolumnWithFocusCellGl=.Column+1\nrowWithfocusCellGl=.Row+1\nEnd With\nspecCell=tFC.Spreadsheet.GetCellByPosition(0,0)\nspecCell.String = tFC.AbsoluteName\neExit:\nEnd Sub \n
Run Code Online (Sandbox Code Playgroud)\n\n

现在,右键单击当前工作表的选项卡并选择工作表事件。分配onSelectionChanged给“选择已更改”事件。

\n\n

另外,创建cfFocusCross带有背景颜色的样式。

\n\n

最后,转到格式->条件格式->管理->添加。

\n\n
    \n
  • 公式为OR(ROW(A1)=ROWWITHFOCUSCELL();COLUMN(A1)=COLUMNWITHFOCUSCELL())+N($A$1)*0
  • \n
  • 应用风格cfFocusCross
  • \n
  • 范围A1:Z100
  • \n
\n\n

突出显示行和列的电子表格

\n

  • @Jonas Stein:好的,代码已随说明一起添加。 (2认同)