Using RPGLE what hex characters do I use to simulate a keyboard ALT/Enter - rpgle

I have several comments that need to go into one EXCEL cell and I want them broken out as each comment. If I'm using EXCEL and I want to perform this, I would use ALT and ENTER. What HEX characters do I use to make this happen?

So if you are using Apache POI to create your spreadsheet, you insert an x'25' which is a newline character. I believe that you also have to set the cell to word wrap to make this work. This code is an EBCDIC new line code, Java converts that to an ASCII new line for you.

Related

Excel newline (char(10)) copy/paste issue

I'm trying to use CHAR(10) to create some nice formatting for some scripting I am generating, but copying and pasting is not working for me. I am running Windows 8.1 atm. Here's a clarifying example. Using the formula:
="hello"&CHAR(10)&"world"
I get hello[newline]world in Excel. Copying/pasting into Notepad, I would expect
hello
world
But when I actually perform that copy/paste, I instead get:
helloworld
Now, I know that the newline is in there, because if I copy that output from notepad into this very window, I get the newline reinserted. I ultimately need to c/p out from Excel into plaintext with (visible) line breaks. Any ideas how I can accomplish this?
A "newline", in Windows, is typically a carriage return followed by a line feed. Those are two separate character codes: 13 & 10, respectively.
So your formula in Excel would need to be:
="hello"&CHAR(13)&CHAR(10)&"world"

Remove Unicode UTF-8 character from string in VBA

I'm using excel vba to take a dataset and build an XML file.
The data comes in with some unicode characters inside some of the comments fields.
This causes problems for the XML.
Would like to strip out any of these non-printable characters during the vba process.
Thanks
WorksheetFunction.Clean() should help: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.worksheetfunction.clean%28v=office.14%29.aspx

Importing txt files to excel makes linebreaks disappear

I am trying to import a text file into excel (2007). The file was exported from a C# text box and it contains linebreaks. Although when I import it (with the text import wizard that comes with excel), the linebreaks disappears completely. I would prefer not to have to write a VBA file and place in an excel file to run but instead change this with a neat method in C#, before it turns the text box data into a txt file. Is this possible in any way?
I figured this out. If you put quotes around text any embedded line feeds (ASCII 010) will be imported into Excel as embedded line feeds. In other words, these line feeds will not cause the text to split across Excel rows.
Try it. Create two files in Notepad.exe. In the first terminate the first line by pressing Alt-0010:
Test line 1 terminated with alt-0010
Test line 2
In the second, begin lines with " and terminate with ". For the first line insert an Alt-0010 just before the ":
"Test line 1 terminated with alt-0010 prior to the quote"
"Test line 2"
Now import both into Excel and see the difference.
See IETF RFC 4180 for more information
In excel a line break within a cell is encoded as ascii code 10 (i.e. \n) (determined through the handy use of the macro recorder and inspection of the generated VBA). I think the 'disappearance' of new lines probably is a result of you're C# emitting \n\r, so you might try doing a global replacement of "\r" with "" in your C# code before outputting it.
Thanks for the help! I tried starting the text with \" and finish with \" but when I go to excel, I get each line in a separate cell and my hopeful plan was to get all the text in one single excel cell.

Import a fixed width text into Excel 2003 using VB

I have a fixed width text file and I want to automatically import certain spaces in each line into specific cells of an Excel 2003 sheet.
Can you help me?
I will re-phrase my question because the previous one wasn't very clear.
I need to read specific characters (i.e. 12-17, 23-29) and place them inside a excel sheet.
Is this possible?
Yes it's possible.
Check the "Fixed length" option in the import wizard and tell Excel how many characters there is for each field.
Excel will parse out any whitespaces and leading zeros when reading text.
If you can, format your text file as CSV with delimited values, and format your values as formulas, like this:
=" Value 1",="0000",=" more spaces ",=" "
This will preserve the values.

import text file containing line breaks into excel

I have a plain text file looking like this:
"some
text
containing
line
breaks"
I'm trying to talk excel 2004 (Mac, v.11.5) into opening this file correctly. I'd expect to see only one cell (A1) containing all of the above (without the quotes)...
But alas, I can't make it happen, because Excel seems to insist on using the CR's as row delimiters, even if I set the text qualifier to double quote. I was sort of hoping that Excel would understand that those line breaks are part of the value - they are embedded in double quotes which should qualify them as part of the value. So my Excel sheet has 5 rows, which is not what I want.
I also tried this Applescript to no avail:
tell application "Microsoft Excel"
activate
open text file filename ¬
"Users:maximiliantyrtania:Desktop:linebreaks" data type delimited ¬
text qualifier text qualifier double quote ¬
field info {{1, text format}} ¬
origin Macintosh with tab
end tell
If I could tell Excel to use a row delimiter other than CR (or LF), well, I'd be a happy camper, but excel seems to allow the change of the field delimiter only, not the row delimiter.
Any pointers?
Thanks,
Max
Excel's open
Looks like I just found the solution myself. I need to save the initial file as ".csv". Excel honors the line breaks properly with CSV files. Opening those via applescript works as well.
Thanks again to those who responded.
Max
The other option is to create a macro to handle the opening. Open the file for input, and then read the text into the worksheet, parsing as you need, using a Range object.
If your file has columns separated by list separators (comma's, but semicolons for some non-English region settings), rename it to .csv and open it in Excel.
If your file has columns separated by TABs, rename it to .tab and open it in Excel.
Importing (instead of opening) a csv or tab file does not seem to understand line feeds in between text delimiters. :-(
Is it just one file? If so, don\'t import it. Just copy paste the content of your text file into the first cell (hit f2, then paste).
If you absolutely must script this, Excel actually uses only one of those two chars (cr, lf) as the row delimiter, but I'm not sure which. Try first stripping out the lf's with an external util (leave the cr's) and then import it... if that does't work, strip out the cr's (leave the lf's) and thenimport it.

Resources