I'm writing an excel file using javascript (the language doesn't really matter) and came across the following issue...
I need to write a cell with line breaks. I have read that I just need to add CHAR(10) to my formula and voila! However, I will have to send this file to different people using different language versions of Excel. Therefore if a French opens the sheet, he will see an error because CHAR(10) should be CAR(10) same for other languages...
Is it possible to insert a line break programatically so it works on every versions?
Related
I have a program which generates an Excel file. Specifically, it's a node app which generates a JSON file which is loaded into GrapeCity's SpreadJS and exported again via their ExcelIO libs. This file has a lot of formulae in it - at least a thousand of various forms built according to various rules from an input data set which is itself non-trivial. Whilst these files load file in SpreadJS and export in such a way that they load in Excel and appear to work, I get a number of errors from Excel when I try to load it:
Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.
Removed Records: Formula from /xl/worksheets/sheet1.xml part
Removed Records: Formula from /xl/worksheets/sheet2.xml part
Removed Records: Formula from /xl/worksheets/sheet3.xml part
After I initially posted this question, I eventually figured out that this was because the formulae in question were using single quotes for text strings rather than double. The question is - without playing guessing games, how could I identify which formulae Excel has removed / fixed? Excel's so-called log file is just a repetition of the equally unhelpful references.
Any of the following would count as good answers:
A way to get Excel to tell me the string of the formula which it has a problem with
A way to get Excel to tell me the cell reference (e.g. F5) of the formula which it has a problem with
An external tool which would do the same
A library or tool for validating Excel formulae which I could run on either the Excel file or the original input which would give me similar output. If it was an npm lib that would be even better
thank you for using SpreadJS.
Can you please share the original spreadjs file (ssjson) with our team, they can perform the export and figure out what might be causing this. In general exported files should not product file open errors, even if the formula is incorrect.
Grapecity Team
http://www.grapecity.com/spreadjs
https://github.com/LesterLyu/fast-formula-parser/ works for verifying formulae.
I'm working on a system that primarily uses TSV files for internal exports, and many of the users who interact with the files only currently use Excel.
I've noticed lately that if a cell contains a comma character: when the TSV is downloaded that cell looks fine, but then if the document is opened, changed in any way and then is closed again: then quote characters are being added around that cell.
So if the file contained the text !house, pm and then the file was in any way amended and saved: that cell would now contain "!house, pm"
Re-importing with the " characters is causing errors all over the place.
Couple Q's:
Is there a way to stop Excel from adding these "" characters?
If not: is there a better program to be using to amend this doc, with similar functionality and format to Excel (especially for non-technical users)? So like a row+column layout, ability to filter, etc?
Libre office does not have this 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"
I am able to write a data frame to an excel file, using the RODBC package.
Now I would like to include some formulas, e.g. =A1, which upon opening the excel file are interpreted as such; including "=A1" as text in the data frame results in a string entry "=A1" in the excel file (the value shown in the formula bar is '=A1), and is not interpreted as a formula.
You need to write your file without quotes. When I constructed a tiny file named testcsv.csv with this as contents:
=B2, 2
... And then used the File/Open ... menu and used the dialog to open it after selecting All Files as the file type, the expected calculation occurs:
(This is on a Mac with Excel2011, <\strike> so Windoze might be different. <\strike>) Works the same on Excel 2007 running in WinXP.
You are better off using one of the CRAN packages interfacing xls file natively -- I had good luck with xlsx; others have reported success with xlsReadWrite
Another possible approach in windows would be to use the rcom package http://rcom.univie.ac.at/.
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.