Is there a way to split the text inside a cell in the attribute table into different lines?
No. it is always flattened for storage
I have to partially disagree with Dan Patterson on this one. I can't say all, because I haven't tried them all, but most geodatabases (personal geodatabase, file geodatabase, SDE geodatabases) do support storing ASCII linefeeds (\n in Python) and carriage returns (\r in Python) in text fields. They can be inserted either through an editor in ArcMap or using cursors in ArcPy.
Even though linefeeds and carriage returns are supported, not all the tools play nice with them. For example, when looking at a text field of a table in ArcMap, you can't see any text after the break, so it is very easy to get confused as to how much text is really there (see UPDATE). Plus, linefeeds and carriage returns involve working with special characters that can also be confusing for folks that don't work with them often.
Overall, I would say the answer to your question is yes, but I typically discourage against folks breaking lines in text fields because it causes confusion and headaches for less knowledgeable users.
UPDATE: My original comment about not seeing text after a break in ArcMap tables is true with standard row heights, but the Table display options documentation does show how to increase row height to see wrapped text and text after breaks. That said, the row height isn't auto expanding so text may still be present that isn't visible in the cell.
I was referring to having the ability of seeing multiline text as one would expect in a table...of course you can store multiline text in a field...but it won't look like you want...
I have done it before...pretend this represents the contents of a record in a text field. It compares what you see with what you want.
>>> amazo_line = "this \nis a\multiline\ntext string\n"
Of course when things get real ugly, I simply hyperlink out to a document...just make sure that you are good with project-data location things.
I believe the most correct answer is "No" you cannot break a database table field cell into multi-line. However as indicated you can place newline markers within the text so it can be printed multi-line or viewed multi-line if your viewer is capable.
When I need to see text data from a table that is better viewed multi-line... I generally open the database outside of ESRI and use the native built-in viewers of the database itself or sql client viewer... most of which have the capability of viewing text cells as multi-line. Another trick is to suck the table into excel and use the excel multi-line formatting.
--Really do not know what your ultimate goal is having that would provide you with more concise answers.
This is what I am trying to do. I have a feature class of buildings; there are different Departments in each building. I want to add all the Department names in a column but when I look at the HTML pop-up window I want each Department name listed in a separate line. For example, one building may have Biology, Chemistry and Physics. I want the pop-up window to show.:
I could have one column for each Department and that would do it, but that's going to make the table really long.
You can do something along these lines.... this is not tested I am just giving you an idea...
# Assuming your column that has the Departments are separated by a consistent symbol
# I will assume the Departments in the DB column are like this Engineering, Finance, Procurement etc
myDepartment = DepartmentColumn.split(",") #Seperate various Depts into a list
myLabel = '\n'.join(myDepartment) #Join each element of the list with a new line
Since you're interested in HTML, have you tried inserting an HTML line break tag between items?
I would guess:
...in your attribute table would be interpreted in the HTML pop-up as:
I thought the same thing, and it doesn't work with default settings. If one is working with custom XSL templates, then many other doors start to open.
Ah, thanks for looking into it, Joshua Bixby
Interestingly enough, I just tried it with ArcGIS Pro, and inserting HTML line breaks works with default settings.
Thanks. That is what I am trying to do by creating a XSL template for the pop-up window. I am beyond beginner in XSL.
In QGIS I can use the calculator with its concatenate operator || and \n to create a multi-line attribute value (e.g. 'text' || '\n' || 'text2'). This displays on opening a table in ArcMap as a single line but on resizing the rows it shows as two lines. In ArcGIS Pro it shows as two lines in the table on opening. In both programs it labels as two lines. In both programs the Identify window shows it as one line and I don't know anyway to change row height in the Identify window.
I have not found any way in ArcMap to manually, or with the calculator, create the same two line field value, despite using the same characters, nor can I copy and paste a two line QGIS created value into another cell as a two line value. But my knowledge is pretty limited.
In ArcGIS Pro I could use the html <br> to make the Identify window show two lines, but on labeling it was a single line with <br> in between.
Retrieving data ...