When converting a selection of text to a table in Writer, there should be an option to spec the desired number of columns. I currently have some text, all separated by paragraph returns, that I would like to make into a two-column table. That seems impossible without, possibly, changing some of the delimiters before the conversion. I'm in LO 5.1.1.3 x64 .deb.
Can you attach a minimal example document with the starting point text and the desired end result table? Set to NEEDINFO. Change back to UNCONFIRMED after you have provided the document.
Created attachment 124231 [details] text that I want to end up in a 2-column table
Puzzled here. This request was assigned to me, the mere reporter?
Looking at the history we can see you assigned it to yourself: https://bugs.documentfoundation.org/show_activity.cgi?id=99035
Yes, sometimes data are not well organized (=> NEW). Example in the attachment is Parameter 1 data 1 Parameter 2 data 2 with the goal to get Parameter 1 | data 1 Parameter 2 | data 2 But I would rather not add this complexity to the text-to-table conversion of _Writer_. If you regularly have to organize data like this you can do the trick with Calc. And eventually an extension/macro could also become handy. WONTFIX in my opinion.
(In reply to Buovjaga from comment #4) > Looking at the history we can see you assigned it to yourself: > https://bugs.documentfoundation.org/show_activity.cgi?id=99035 My apologies. I'm new at this and must have hit the wrong button.
One developer on IRC would rather see this made as an extension or simply a macro.
Hi Paul, (In reply to Paul from comment #0) > I currently have some text, > all separated by paragraph returns, that I would like to make into a > two-column table. I do have a very simple trick for that: I add one Tab (for every extra column) on one line, before selecting and hitting Ctrl+F12. So personally I would not dare to ask extra UI stuff for that. Would that work for you too?
@paul: please consider to ask questions too at one of our great community support options http://www.libreoffice.org/get-help/community-support/
He wants to make from text (oriented in one column) a two column table - there is no extra column. Without manually changing the data I don't think it is easily possible to do it in Calc, or am I mistaken.
(In reply to Tomaz Vajngerl from comment #10) > He wants to make from text (oriented in one column) a two column table - > there is no extra column. Without manually changing the data I don't think > it is easily possible to do it in Calc, or am I mistaken. Depends on the actual values. You can split text into multiple columns and create a pivot table with the running numbers as row criteria. But back to Writer: Another example could be P1 #9 D1 #9 P2 #9 D2 P3 #9 D3 #9 P4 #9 D4 (#9 as tab, could be any other delimiter) again with the goal to get P1|D1 P2|D2 The request is to have an option to limit the number of columns. E.g. [ ] auto split split into [2]+/- That means to ignore line wraps (#10#13), or rather virtually replace by a delimiter, if the number of columns is not reached. And to add a line break otherwise even when there are more delimiters if the specified number of columns is reached. Perhaps it's not so difficult to implement, and from the UI POV I changed my mind and guess user will understand the solution (OTOH undo is always possible).
I'm sure it is not difficult - should be a nice non-trivial EasyHack.
In retrospect, I can see how the request would seem somewhat esoteric. It's been a while now, and I don't recall the nature of the file I was up against, but I do know it was a massive problem, and that I felt it was one I would encounter fairly often (I format a lot of scanned documents - or at least, was, before taking a new job). I guess that by macro I could replace every !Nth linefeed with a tab. That seems a remote solution for the typical user, but it may be the best solution unless I can recall the original problem in greater detail and it proves to be common enough to warrant a GUI solution (as I thought it was at the time).
EASYHACK, please add the code pointer (=> NEEDINFO). The UI needs only small changes with the addition of a (by default marked) checkbox "auto split" and a numerical stepper below that is enabled when this checkbox is switched off (all below the "separate text at" options). Auto split means every break counts, while the numerical input defines how many columns the result will have. See also comment 11.
Changing status: NEEDINFO -> NEW Adding keyword 'needsDevEval' [ninjaedit]
Revisiting this, after quite a while (sorry, wasn't feeling too well back then). I tried the trick of adding tabs to the first line, and indeed, this creates a table with a corresponding number of columns, which is pretty neat. But the data is not filled into those extra columns, they remain empty. The data continues to be populated, each line into a new row. IOW, if the original text is: word tab tab word2 word3 word4 word5 word6 It converts to: word col2 col3 word2 word3 word4 word5 word6 Whereas I would like it to be: word word2 word3 word4 word5 word6 I format a lot of older public-domain documents, and I run into this frequently. My personal take is that this functionality is pretty basic. I'm surprised there hasn't been more call for it. Since I seem to be the only one desiring this function, I think asking over at the Ask is a good idea. I suppose a macro converting linefeeds to delimiters within a selection, while leaving every Nth feed untouched, would be the solution, applied before table conversion.
(In reply to Paul from comment #16) > I suppose a macro converting linefeeds to > delimiters within a selection, while leaving every Nth feed untouched, would > be the solution, applied before table conversion. True. If you start with an extension please share the result so that we can close this ticket eventually. But I could imagine that more users benefit from the change and would keep it as easyhack as long no solution is available.
Ok, I asked and received a really nice macro reply. I slightly altered it by adding an Input box to spec the number of columns on the fly, and to exit if the input box was left blank. The Ask thread is at http://bit.ly/2ETWnbD. I will print the finished macro below. But there is one strange problem. Though the macro works fine when invoked from the Basic editor, it errors out when I use a custom Menu entry for it. The error is: A Scripting Framework error occurred while running the Basic script Standard.Module1.Writer_SelectionToColumns. Message: wrong number of parameters! Also errors out via hotkey. Here's the macro. I would like to see something like this incorporated into Core somehow. :) Sub Writer_SelectionToColumns( ByRef iNumColumns As Integer, Optional sSeparator ) REM Courtesy of librebel, 2/19/18; http://bit.ly/2ETWnbD. My input box added REM Convert selected Text into a specified number of Table Columns. REM <iNumColumns> : The number of columns for the Table to be created. REM <sSeparator> : String pattern separating the Text portions to be inserted into the Table Cells. REM NB. This method does not preserve the existing text format of the selection. REM TODO: Format text; AutoFormat Table. Dim oDocument As Object : oDocument = ThisComponent If oDocument.supportsService( "com.sun.star.text.TextDocument" ) Then Dim iNumColumns As Integer iNumColumns = InputBox("Enter desired number of columns (blank = 0)") If iNumColumns <= 0 Then Exit Sub If IsMissing( sSeparator ) Or sSeparator = "" Then sSeparator = chr(10) Dim oSelection As Object : oSelection = oDocument.CurrentController.Selection.getByIndex( 0 ) Dim aParts() As String : aParts = Split( oSelection.getString(), sSeparator ) Dim iNumRows As Integer : iNumRows = ( 1 + uBound( aParts ) ) \ iNumColumns If ( 1 + uBound( aParts ) ) Mod iNumColumns > 0 Then iNumRows = iNumRows + 1 REM Ceiling()... If iNumRows = 0 Then Exit Sub Dim oTable As Object : oTable = oDocument.createInstance( "com.sun.star.text.TextTable" ) oTable.initialize( iNumRows, iNumColumns ) oDocument.Text.insertTextContent( oSelection, oTable, True ) REM Replace selection with Table. Dim i As Integer For i = 0 To uBound( aParts ) oTable.getCellByPosition( i Mod iNumColumns, i \ iNumColumns ).setString( aParts( i ) ) Next i End If End Sub
Ok, I fixed it by taking the "iNumColumns As Integer," out of the Sub definition: Sub Writer_SelectionToColumns( ByRef Optional sSeparator )
*** Bug 146841 has been marked as a duplicate of this bug. ***