Multiline Fields

I am attempting to import a legacy “database” (currently a .xls file) to a new Base database. The difficulty is that multiline cells lose their multiline character on import.

At present, the .xls cells are made multiline though use of the invisible character within the cells; these cells are being imported into Base fields designated as “Memo” type (and on import I get “too long” error messages but the material seems to come in). However, on import, it loses all line breaks within cells.

Example: the .xls file’s cell might look something like

1 1/2 cups chicken stock
8 oz fresh/refrigerated rice cakes
1 1/2 Tbs gochugaru

(and so on for a variable number of lines, each line ending with a character in the existing .xls file)

but when imported, whether or not checking the CR/LF block in the import wizard, this results in

1 1/2 cups chicken stock8 oz fresh/refrigerated rice cakes1 1/2 Tbs gochugaru

which is obviously unusable. So, what has gone wrong here? (Note: I’m using a “recipe” as a sample template here because it’s a fairly clear example; due to the highly variable number of lines in each cell, ranging from 3 to 40 or so, they CANNOT be converted to individual fields, especially since in the actual database some of those lines are not actually independent of each other but are single data elements that have to output and be edited in a multiline format.)

  • Does the .xls file need to include a dummy character instead of the , that can later be mass-changed in the Base file (and if so, I can’t find a clear explanation of how to do this to change to within-field CR/LF or equivalent)?

  • Is there a different choice or parameter I need to set during import that I’m just not seeing as an option?

And here I’m annoyed by the bulletin-board system, which did not allow me to say ctrl-J inside angle brackets – that is, standard notation – and instead silently treated that as a null.

Each of the lines within the cells ends in ctrl-J in the .xls file, which creates a line break but not a “new paragraph.”

It is 117436 – Export to Calc and import from Calc: Line break isn't exported through copy and paste.
.
It will work well if you create a Base file, which directly connects to the *.xls file. Then copy the table of the *.xls-file into a Base file, which connects to the database you want to use.
.
Note: Base isn’t a database. Base is a GUI, which could connect to different database types. There are, for example, 2 internal databases: HSQLDB and Firebird. You haven’t written which database you are using. Might be the default internal database HSQLDB.

Connect a Base document to the spreadsheet.

  • File>New>Database…
  • Connect to existing db of type “Spreadsheet”
  • Drag table icons into your database. The line breaks will be preserved.

Before doing that, you may want to separate your sheet tables from other cell contents on the same sheet (formulas, helpers, drafts). Select the rectangle of cells representing the actual database table and call menu:Data>Define… which will create a named database range which will be represented in Base as a separate database table

“Connect to” is not a solution. The data must be fully imported, as the machines that host the data will not have persistent availability to the machine on which the Base file will live.

If I understand Robert’s comment (with a pointer to a bug) correctly, this is an actual flaw in Base at present. If so, is there a workaround, such as a global search-and-replace (an SQL query is not acceptable, this must modify the data as stored, permanently) that inserts the CR and LF characters (ASCII 10 and 13)? If that’s the appropriate workaround, does the Base file need to have the “recognize CR/LF within memo field” parameter set BEFORE importing data, or can it be set after importing data but before doing the search-and-replace?
Better yet, can all of the search-and-replace be done in Calc and then recognized on import to Base, IF the Base field is preset as “memo” and recognizing within-field paragraphing? (And can Calc handle that or will it assume that seeing both a CR and LF means “new cell,” like older versions of Excel — including one of the source files for the actual database — did?)

I was also unable to complete this task, using Calc.
In the “transit” DB which directly connects to the Calc file, multiline text displays :ok:
In the real intended DB:
Paste or drag > Table = “Sheet1” > Create pk “ID” > Type formatting > Create > Refresh Tables = nothing.
:thinking:
NoCorrespondingColumns
Tables
TypeFormatting
 
Tried it all ways I could imagine to no avail.
Made pk Decimal apparently :ok:
then


 


Screenshot from 2026-07-26 21-28-02

There will be 2 Base files:
1 File, which connects to the *.xls-file (for example: DB_xls.odb)
1 File, which connects to the database you want (for example: DB_HSQLDB.odb)
Copy the tables from DB_xls.odb to DB_HSQLDB.odb and the multiline fields will be copied if you set the type for the field to “MEMO”.
grafik
Looks like this: “Name” is only VARCHAR, “Memo” is set to Memo [ LONGVARCHAR].
.
Don’t copy tables from Calc directly to DB_HSQLDB.odb, because the multiline content will be shown only in one line.

[Firebird]
Was now able to complete the task.

  1. Insert a numeric id in A

In the “independent” (second) DB:

  1. set pk type = DECIMAL, no auto;
  2. set text type = BLOB SUB_TYPE TEXT.

Gares of Paris inserted in this DB.
 
ColumnsMapping
MultilineForm

This is a list within a single cell. I would split these list entries into separate values linked to some table of ingredients. This is what relational databases are made for.
Have a look at https://ask.libreoffice.org/uploads/short-url/wlNcbmtBFiRqN1PbRXSc3KX0MkI.odb
There is a table of ingredients, a table of recipes and a third table mapping ingredients to recipes. The mapping table looks like this:

M_ID I_ID Q
0 23 1
0 26 1
0 28 1
0 29 1
0 44 1

There is a meal-ID #0 consisting of ingredints #23,26,28,29 and 44, one unit of each ingredient. The details about each ingredient is stored in the ingredients table with name, quantity unit, nutrition values. The table of meals stores a name and some arbitrary comment.
I added one form showing the meals and their ingredients with accumulated nutrition value per meal[1] and another form showing all ingredients and the recipes where they are used.

If you are not familiar with relational databases, you can

  1. Create the necessary structure (tables and relations) to store the data. Or simply re-use my database.
  2. Do all the splitting on spreadsheet, so the split data fit into the tables.
  3. Copy over the naked cell values (no multi-line).

EDIT:
[1] The nutrition values are accumulated in the report. Could be done in the form just as well.

ask136641.odb (11.3 KB)

Yet another simplified sample without nutrition values. You enter names and comments into the meals table and multiple lines of ingredients into the ingredients table. Each ingredient is stored with the meal ID it belongs to. This is a one-to-many relation where each meal has many ingredients.

The other sample implemented a many-to-many relation where each meal has many ingredients, but also each ingredient (with its nutrition values per unit) belongs to many recipes with varying amount of units.

To quote the initial request:

(Note: I’m using a “recipe” as a sample template here because it’s a fairly clear example; due to the highly variable number of lines in each cell, ranging from 3 to 40 or so, they CANNOT be converted to individual fields, especially since in the actual database some of those lines are not actually independent of each other but are single data elements that have to output and be edited in a multiline format.)

Please read the entire description before dumping in suggested solutions that don’t actually fit the data set. It should be darned clear from the entire description that this isn’t a “recipe database,” but that “recipes” are a clear example of the problem. If I wanted to design a recipe database, I would have asked for that. There are confidentiality-of-source-material issues here that result in variable input formats, inability to make this a multitable fully-relational system with SQL bells and whistles, and so on — combined with differing hardware issues. I know what I’m asking for: A solution to a specific data-import problem that cannot be “solved” with a massive retrospective design change.

There is no db_hsqldb.odb in the folder (only the db.odb), either as a separate file or visible in the Base window. Where is this? How is it accessed? And, perhaps most to the point, where is anything related to this documented (either in the manual(s) or help system)?

And, again, “connects to” is not an option, unless there’s a language barrier on “connects” that I’m just not understanding. This requires a hard one-time import of multisource data that shares some, but not all, characteristics of a “recipe file.” Often there’s little or no choice of how data was originally stored/created. The data can be further manipulated/managed later; first, though, it has to come in, properly, with integrity.

And what do you see in the Tables panel of this (HSQLDB) .odb?

@BruceTheShark : Your Base file has name “db.odb”? This is what I called “db_hsqldb.odb”, because I thought you have created a Base file, which will use a HSQLDB database. This is the default internal database most people use.
No do this:

  1. File → New → Database
  2. First Step → Connect to an existing database → Spreadsheat
  3. Second step → Browse to the *.xls file
  4. Third step → Save this as DB_xls.odb

Now there are 2 different Base files. One connects to your new internal database (“db.odb”), the other connects to your *.xls-file (DB_xls.odb)

Copy the table from DB_xls.odb to db.odb. When inserting the table choose Memo [LONGVARCHAR] for the field, which should show linebreaks.

If you want to keep the structure of your data set, you should stick to Calc/Excel. We can not know what you are after because all you show to us is the content of a single multi-line spreadsheet cell.
Whatever you try to do, a database lets you overcome lists in single cells.

We have a language difficulty here that’s preventing me from fully understanding your responses. I’ve said several times that “connect” is not an option, and responses keep coming back “connect.”

“Connect” means “maintains a persistent link, and relies on the already-existing data source as the only copy, however it may be later edited (or not).” “Import” means “copies from the already-existing data source (which can then be forever disregarded) into an internal table.” I’m asking about “importing,” but responses keep coming back telling me to “connect.” I suspect this is a German-colloquial-use thing (and my data-processing-colloquial German is not up to task), but it might also be an actual incapability that appears inconsistent with the documentation. (There’s also a notation issue; I took the underscores like in “DB_HSQLDB.odb” to be parts of filenames or table names and not descriptions, because that’s what an underscore-instead-of-space means to me.)

There is one, and only one, .odb file at issue: The target Base file that should end up with all of the data from the multiple sources that have to be hand-massaged on the way in. The source material is currently in .xls files from which the data needs to be imported because once the import is complete, there will no longer be access to the .xls files. Thus, “import,” not “connect to” as any part of the process.

I’m going to try asking this an entirely different way. By using what I thought was an obvious simplified example, a bunch of tangents have derailed the thread.

Consider a brand-new, completely unpopulated Base file in which one field in the only data table is designated as the “memo” type, and for each record that field is to contain a variable number of PARAGRAPHS that may be a single line or even more than 300 words (visualize “narrative on annual performance report” with linguistically separate paragraphs that are not data-processing-separate fields). The original data source, multiple .xls files, separates these PARAGRAPHS with line feeds ( ctrl-J on the keyboard ), but could be search-and-replaced to use any arbitrary character (like “@@@”) during the transfer process. The original data sources will NOT be available for later access: This ia a one-time import, and everything must end up inside a single table .odb file.

The “memo” field type appears from Base’s documentation and design to allow “multiparagraph” entries, and that’s what I’m trying to do with the imported data. The use of ctrl-J (which should translate directly to ASCII decimal 10, the line feed/LF character) works inside of Calc, Excel, and older spreadsheets… all of which blow up if they find ASCII decimal 13, the carriage return/CR character, inside of cells. Thus the present intermediate coding of LF only. The objective is to consolidate all of this data in a single location, at which point new records can be added and existing records edited without ever touching (or Base even knowing the existence of) the original data sources.

I’ve been unable to find a way in the current documentation and help system to take that imported data and reimpose paragraph breaks, in a memo-typed field, where there are supposed to be paragraph breaks — notwithstanding the apparent capability for the memo-typed field to contain multiple paragraphs. This would also apply to any other multiline input “cell” (individual record for that particular field), such as old-style addresses for non-modern postal systems, lists of ingredients or equipment, record-unique safety/verification checklists, and other non-separable-into-independent-field data; thus the initial question’s reference to “multiline.”

to fill up the so to speak “transit” table in the “intermediate” DB “DB_xls.odb” as per @RobertG’s nomenclature.

Of course. After inserting the data from “transit” table into table of the definitive (“destination”, 2nd) DB, import is finished.
As you can see above, I inserted Paris’ gares names in this permanent DB. No relation with the old spreadsheet.
Record #3 has no relation at all with the original Spreadsheet “database”:

This is the start of the problem: A Base file is only a GUI, which connects to a datasource. Have a look at the status bar of your “Base file”.
grafik
If you have “created a Base file” this will be the default. The Base GUI connects to an embedded database. It is called HSQLDB.
grafik
This is a Base file, which connects the GUI of Base with a spreadsheet. The status bar will show the connection to the Calc file “Calc_Linebreak.ods”.
.
I created this file only for copying the tables from Calc to the Base file for the embedded database. There won’t be a (permanent) connection between the embedded database and the Calc file.
.
You could also copy tables directly from a Calc file to the Base file with embedded database. But you won’t see any linebreak in the imported data when copying this way.

3 STEP Solution without steps 1 and 2
In the destination “db.odb” DB
1

CREATE TABLE TT (TEXTO BLOB SUB_TYPE TEXT NOT NULL);

without pk!
2
Drag the linked table from “DB_xls.odb” over TT icon in “db.odb” DB
> Append data.
3
Create the real production table “Table2” the usual way:

  • ID pk auto
  • TEXTO BLOB SUB_TYPE TEXT

4

INSERT INTO "Table2" SELECT TEXTO FROM TT;

 
Tabela2

(Been away for a few days)

This is at best a partial solution… because more than five records or so runs into a problem with the index field and the error messages are simultaneously self-contradictory and unhelpful.

I have tried importing with preset values in the Key field (ID is a reserved name for other purposes), with a blank Key field, and with no Key field attempting to add another key field later (using the wizard’s defaults or doing it manually, even renaming the ID field in the existing database to something else and allowing the default ID name). It doesn’t work; I keep getting “type mismatch” errors that don’t tell me what IS supposed to match; one would think that the add-a-new-primary-key in the wizard would do so without a type-mismatch problem, but no.

I was able to import a five-record subset database using the connect-to-spreadsheet | create-new-database | copy-table sequence, which showed the LFs properly – but it was uneditable without a primary key, and with a larger subset of 40 would not import at all (every record gave an error).

I’m trying to ensure that this data will be accessible, editable, and analyzable WITHOUT using SQL or queries, and WITHOUT using a proprietary database. I’m rather frustrated. (And there are way too many records to continue relying on spreadsheets.)