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
Related
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.
A semi-well-known bug in Excel for Mac 2011 causes it to mangle imported .csv files containing accented Unicode characters. See: Microsoft Excel mangles Diacritics in .csv files?
For example, Pérez might get imported as Pérez.
My question: has this been fixed in Excel for Mac 2016?
No this has not been fixed in Excel for Mac 2016 and still miss-imports "Pérez". You can fix it in Excel by opening a New Worksheet, then "Import" and specifying UTF8 as the encoding. However there does not seem to be a way to construct a CSV that can be imported without knowing beforehand that it is going to Excel.
This is a workaround for my own particular UTF-8 problem, refers to tab-separated values rather than CSV, and also involves proprietary software*. Hence it may not be of general applicability. However I am posting it in case anyone else finds it useful or is able to adapt it to their problem.
I work with a UTF-8 MySQL database which contains one field with UTF-8 text because of Greek symbols. After making an SQL query I often paste from my Mac terminal into the BBEdit text editor, do some minor clean up, and then import into Excel for distribution and presentation. Having read the answer from #MitraArdon, the following allows me to preserve the UTF-8:
Set the BBEdit text document as Unicode (UTF-8, with BOM)† using the selection options at the bottom of the page.
Launch Excel 2016 and import the text file (as delimited text — I use the pipes from the MySQL tables as delimiters). Save as .xlsx.
There is no step 3 (as the ad used to say).
For the reverse process I cannot do the normal “Save as tab delimited text” as the Greek letters will be replaced by underscores. As the document is in UTF-16 one must:
Select “Save as UTF-16 Unicode Text (.txt)”
Open in BBEdit and change the format to UTF-8 (generally ‘No BOM’).
Then I can upload back into my UTF-8 MySQL database, if required.
Footnotes
*Actually BareBones’ cutdown free text editor, TextWrangler, should also work as it has the option to save as UTF-8 BOM.
†Or convert to UTF-16 BOM.
I want to export Excel to Tab delimited (.txt) file with special character.
I've changethe format to UTF-8, but it still doesnt work.
The origin data is like Mädchen and what i got is M?dchen
Anyone can help me? Thank you
This was similarly asked and answered before: Excel to CSV with UTF8 encoding. Take a look at Eric's answer.
The best way to do it is to save the file as an Unicode text file. And save as the unicode text file, change the encoding to utf-8
Save it as Unicode text file. It will still save as Tab Delimited and preserve all the versatile non-English characters.
I have list of students and i want to invert the "Name Surname" format to "Surname Name".
My problem isn't the coding, but it's the UTF-8 support for my language.
I tested the macro with looping through the names and displaying them in a msgBox, but i get question marks for every name.
Anyone else had problems with UTF-8 in Excel Macros?
UTF-8 and Unicode mean different things, so it's hard to understand what you're asking for.
In principle, VBA uses 2-byte unicode (UCS-2) internally. This is not the same as UTF-8 which many external programs expect.
The StrConv() built-in function can convert back and forth.
How can i read special characters in excel. For example ö is changed into ö and a hyphen (-) is changed in to â€
Is there any way to make it read all my characters like it should?
Thanks in advance.
By "special characters" you mean non-ASCII standard characters. You probably need to convert your file's encoding to Unicode (UTF-8). The way I do it is to open it up in notepad++ and hit convert to UTF-8. Save the file and it should open up in excel