When I try to encode a HTML anchor link in CSV file cell it becomes corrupted and not readable by Excel.
Is there some sort of non-HTML solution or format to encode a hyperlink in CSV file cell?
For when automagicalism doesn't work, and you're definitely using Excel, use this as the field content.
=HYPERLINK("http://stackoverflow.com")
This worked for me:
Use the =HYPERLINK function, the first parameter is the web link, the second is the cell value.
Put " quotes around the entire function.
Escape the internal quotes within the function with two sets of quotes, i.e., ""
Here's a four-column comma-delimited example.csv:
5,6,"=HYPERLINK(""http://www.yahoo.com"";""See Yahoo"")",8
When a spreadsheet program (LibreOffice, etc.) opens this .csv, it creates an active link for you.
What worked for me in Excel 2003 - output to your CSV the statement:
CELLVALUE="=HYPERLINK("+QM+URLCONTENTS+QM+";"+QM+"URLDISPLAYNAME"+QM+")"
note the semicolon ; use in the hyperlink. I've found the comma not to work for me in Excel 2003.
Depending on the script or language you use quotemarks could be handled differently. The cellvalue you put into the CSV before you import it into Excel should look exactly like this: "=HYPERLINK("URLCONTENTS";"URLDISPLAYNAME")"
where:
CELLVALUE is the output written to the CSV
QM is the ASCII value of ["] -> (ASCII 34)
URLCONTENTS is the full URL to the page you want to link to.
-URLDISPLAYNAME is the text you see in the Excel cell.
You can also use relative paths and set a base location in Excel.
File/Properties > Tab Summary > Field Hyperlink Base.
Use as fieldvalue something like http://www.SITENAME.com/SUB_LOCATION/../SUB_LOCATION that sets your starting point so you can click it in Excel. Of course, you don't have to use SUB_LOCATIONs if the sitename itself already will resolve successfully for your relative path.
What I couldn't find is how to make the links automatically underlined in Excel. From other tips found in this article:
Format manually all linkcells as underlined and darkblue (for example) and then the standard functionality appears with already visited links turning into another color.
A CSV file is simply text - it's up to the loading program how it chooses to interpret the text.
If Excel is complaining when you feed it "Link", "another cell" then try just having the raw URL and you might find Excel will automagically turn it into a link.
But in general Excel doesn't process HTML, so expecting it render HTML from a CSV file is asking too much.
Related
I've found a similar question, but the answer didn't solve my issue. I'm trying to do a similar thing as this post, but I'm not sure if my original Excel cells are populated with the same thing.
Mine don't have a fixed link, but rather reference other cells using the following formula:
=HYPERLINK("https://www.website.com/search/?search="&B2, "View")
I've tried running the VBA code from the linked post above, but no luck. Is there a tweak for this to populate the resolved URL into the proper HTML code using "View" for the hyperlink text? The value in cell B2 is a number, let's say 12345.
So I'd like the end result to populate the cell with:
<a href="https://www.website.com/search/?search=12345>View</a>
End goal: I'm trying to export the Excel data as HTML table code, so trying to prepare the cells for proper HTML format to display the links on the website. Any export method I've found just exports the hyperlink cell as plain text "View" which is obviously not the desired result. If I can convert these cells before the export, then that solution would work fine.
Alternately, if there's a way to directly export the entire spreadsheet to an HTML encoded table (while also converting the hyperlinks as above), that would be even better. Note: the export to website function within Excel (using 2016) does not work...I need simple, plain HTML list code that doesn't reference the original spreadsheet.
Sorry if I've misunderstood your question, but does this help?
Function for Column B
="<a href='https://www.website.com/search/?search="&A2&"'>View</a>"
I do the following:
from docx import Document
document = Document('text.docx')
document.paragraphs[42].text
And it gives me '' whatever number I enter, and for loop to find and replace a word does not work. But if I save the document with document.save('text2.docx'), the document is not empty.
The document is relatively big and contains many different formatting, images, tables, styles.
My task is to find and replace a word in docx document with some correction of the following word, so I will be glad, if you suggest another tool
I ran into this problem and was able to read the document using docx2txt: https://pypi.org/project/docx2txt/
I have a super simple MS Access form with two fields to collect some data quickly, one of which is a memo data type, wired into a table field. I want to copy some formatted text from HTML into it and would like to preserve the formatting (bolding, fonts, italic, etc.). However, when I do Ctrl-C --> Ctrl-V, it only pastes unformatted plain text.
Is there any way I can configure my form field to accept and save formatted text? If I paste the same into MS Word, the formatting IS preserved.
You will have to open the 'source' of the HTML file, and only then copy+paste.
From the browser, you'll just see the HTML output.. and some apps, like Notepad, won't be able to store the data through a simple copy+paste. MS Word can do it, as you might already know, since it is a rich-text editor.
As for a field in MS Access, you can only preserve the formatting if you copy the source itself. It will help if you let us know which browser you are copying from, though normally, there is an option to view the source code of the page being viewed.
[edit:in response to comment]
If you want rich text to enter into an ms access field, try the first few steps here: http://office.microsoft.com/en-001/access-help/insert-or-add-a-rich-text-field-HA010014097.aspx
I guess the question says it all. My app outputs a plain text CSV file with month/date shown without separating character. This is plainly visible in Notepad. I even tried putting quotes around it for clarity. Calc, instead of showing what is plainly written there, shows this BS not just in the table but even in the edit cell textbox.
When you're importing the CSV to Calc, select this column and change its type to "text", which will prevent Calc to parsing it as a number/datetime.
Then, on the spreadsheet you have enough tools to easily parse it to the value you want. And by "tools" I'm mean formulas like value, mid, date, etc.
O have a ,,export to excel" function, I have some tables and it works fine, but I have one single problem.
For moving to the next line I use <br />, but what if I want to switch to the next column? What tag can I use to switch to the next column?
Thanks
Simple HTML tags are supported on a limited basis by Excel. There used to be a list of supported HTML tags as well as some HTML extensions supported by Excel (from Excel 97 onwards), but I can't find it on MSDN anymore. Here's an alternate link:
http://www.code4lifesoftware.com/articles/msexcelreadme.htm
The new XML/HTML format supported from Excel 2000 onwards is a lot more complex, and requires more work:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoffxml/html/ofxml2k.asp
Take a look at these links, hopefully you'll find the syntax you're looking for!
In all Excel versions where I used this approach no other way to go to another column, but to use the table. You can mark up your html file with a table layout (although this is not recommended by W3C), and place all of the nested data table inside the main layout table. Unfortunately no other way.
P.S.: Look at Excel html format: Saving and Opening HTML Files.
The BR tag has a mso-data-placement style attribute specifying where the data is stored. The attribute can have one of the following string constants: new-cell means to start a new cell in the next row after the break and same-cell means that the break is in a cell.
If you use commas and make your file a .csv, that would be one way. If you use tabs, then have it read as a tab delimited file. Basically, you need to tell Excel what your delimiter (separator character) is, and it will handle it from there.