Automatically format .csv file upon download? - html

I have a form that will open a file based on user's selections. A few files are .csv and those files open up in Excel, as expected. However, everything is placed into one cell... I know that there is a way to manually configure it so that the | or , are delimiters, but is there a way to set it so that Excel will automatically set the | as a delimiter?
Thank you in advance!

Because you use the word "download" and your question is tagged "html", I assume that the user interacts with a web form rather than a desktop form.
In that case, it's the web browser that decides what to do with the file. If the browser recognizes the content-type of the response as something it can handle natively (e.g. "text/plain" or "image/jpeg") then it may open the file and display it directly.
However if the content-type is not something it knows how to deal with (which is likely the case with "application/csv"), then it will download the file and ask the operating system to open it. At that point, the filename assigned to the file (which can be set via the HTTP response) may come into play.
On a Windows machine, the operating system maintains a list of file extensions and actions associated with those extensions. When you install Excel, that will normally make Excel the default "open" action for files with the ".csv" extension. That's why double-clicking on a ".csv" file opens in Excel, and also why it may open in Excel if you download it from a website. (If you didn't have Excel, it may simply ask you what program you want to use).
This is a long-winded way of saying that if you had control over the user's machine you could give the file a different file extension and then associate that extension with an action that did something different. But, I assume that you probably don't have that sort of control unless you're dealing only with in-house users, and anyway it would not be a trivial thing to achieve.
I don't think that there's any way to communicate to Excel via the command line that it should use a particular delimiter when opening a CSV file, and that - unfortunately - is the mechanism by which the operating system will ultimately open the file.
It is possible to control what Excel uses as the default delimiter for all CSV files (see https://superuser.com/a/606274/18472) but again that would require you to change the system-wide settings on your users' machines, which I imagine would not be possible.

Related

Save As - html thymeleaf

we need to develop an application similar to the below
On the web page user is asked to select the parameters which are present in a Map<String,Boolean>. Once the user selects his choice of parameters then this Map is saved in a .DAT file. Right now I am saving it in C:/Users/Application. But I want the user to choose which directory he wants to save. I was tempted to use <input type="file".....> but it needs a file in the directory.
Is there any way that the user can specify his own directory where this .DAT file is saved.
Something similar to SaveAs..
A webpage cannot choose where the user will download a file that is returned. For some file types, the browser might even show the file instead of downloading it (e.g. PDF file).

save html page from the server by URL with no changes - get the exact copy, the clone

Let's say I have a URL http://example.com/path/to/document.html
That's the html document, the file, that has no external css or js.
If I open it in Google Chrome and save it with Ctrl+S locally, the content is changed. The content of that html file starts with <!-- saved from url= which is not I want at all. I need to get the exact html document, even spaces count.
The second option is to copy it with Ctrl+U (View Source), Select All and paste it into new document, save it and rename it. This is better, however spaces, tabs and end of file will be different depending on what operation system I'm using.
I need the exact copy of that html file - byte to byte.
How to make it?
This is a practical question as I need slightly modify that document.
I'm sorry there is no any source code in my question, but this question is about web developing.
Any ideas?
Thank you.
P.S. Of course that document could be generated by php or whatever, the part of the code can be even extracted from the db, but not in my case. I know that's a plain file.
I'd delete the comment after saving from Chrome, use wget in a linux environment, or open the page as an InputStream in Java. Do all three, run a diff, and if two arrived identical assume that's the file on the server.
Why do you need a byte-for-byte copy of the file on the server anyway, and why can't you ftp the file? There is always the chance that the server will serve different html files depending on your user-agent, but there are other tools which may be better than Chrome for getting your copy and many can spoof a user-agent as well.

Merge multiple access reports to one pdf file using vba

I wan't to merge multiple access reports to one pdf file using vba code. This vba code needs to work on the computers at my work. These computers only contain Adobe Reader, and I am not able to install Acrobat because I am not Administrator. So now my code generates for all the reports a seperate pdf. I had some code to merge these pdf files to one pdf file where I use 'Acrobat.CAcroApp'. But i get an error on line:
Set AcroApp = CreateObject("AcroExch.App")
I think I am not able to do this cause the computers only have Adobe Reader installed. Is there a possibility to create one pdf file for multiple reports/pdfs without using Acrobat.
Thx in advance
2 solutions.
Make a master report that has each individual report embedded as a sub report. If it's just a few, it should work fine, but too many may bog down / crash the application.
Here's a VBA way of doing it here.
Without acrobat reader this is indeed not going to work. I, however, am using the following dirty workaround for users without acrobat;
Export all your reports to rich text ("*.RTF" format) in the same folder. Afterwards, you open a word application via access vba, and loop through the RTF files and then copy them into your word file, with a page break after every insert. Then, you save the word document as a .PDF file.
This is a method prone to errors, so if a more experienced user has a better way, please do tell. I'm interested as well!

Is it possible **to change an .sql file extension to like .myname** and still the software like wamp or sqlite can still read it?

Is it possible to change an .sql file extension to like .myname and still the software like wamp or sqlite can still read it??
-I was just thinking of the possibilities that changing the file extension to something custom could add to db security.
Using sqlite3 in Python you can select any arbitrary file extension (as long as [a-zA-Z]{1,...}) without hindering the module in accessing the database-file.
Note, however, that changing a default file-extension to a different arbitrary one does not increase (or decrease for that matter) security of the data stored in the database in any way.
You'd have to test if other (SQLite-)implementations allow custom extensions as well, but either way, it would have not impact whatsoever on security.
So long as the software in question does not limit itself to only recognizing files ending ".sql", it makes no difference whatsoever.
A file extension is just a label - they do not affect the actual physical contents of a file in any way, and an SQL file is just a text file. That .sql extension is really more of a user aid than a software aid - whilst software will use it as a filter (such as only showing .doc files by default on Word's Open dialog), if you tell a program to treat file X as a file of format Y then it will attempt to read it as a Y-formatted file, regardless of extension.
You could change it to .txt and (under Windows) it would open in Notepad instead when double-clicked, or .doc and it would open in Word (probably incorrectly, as Word would attempt to parse it as a Word-formatted file, not a plain text file). The actual contents of the file are completely unaffected.
You could change the .sql to .txt or .doc or .bmp or .wahoo or anything (or even remove the extension entirely), it will still be readable by WAMP etc.
It will have absolutely zero effect on security.

HTML 5 - load text from text files

I am facing problem in HTML 5. I need to statically load data into web page from local saved files. Up to now, I have been only able to load data via < input type="file" id="fileinput" / > but I want to load data from static location, which never changes. How to do that? And is there any way how to determine, whether some local file was changed from previous version?
Thanks
no, this isn't possible if by 'local', you mean a file at /home/waypoint/somefile.txt. You can make a 'link' with the filesystem api (if you selected it in an input field, for instance), which is valid to do computations with it (to read it, write to it, display it in img,etc). But it is deleted/unvalid, as soon as the window closes. If you could just magically "read" any local file via javascript which resides on the file system, who would stop google to read out your /etc/passwd file?
if your local computer is also your server and therefor your server-side code has access to the local file /home/waypoint/somefile.txt, your app can get it via ajax. Checking if the file exists, would be done the same way.