Save html table data locally with electron - html

I'm new to coding and its a lot of try and error. Now I'm struggling with html tables.
For explanation: I am building an Electron Desktop application for stocks. I am able to input the value via GUI in an html table, and also export this as Excel file. But, every time I reload the app, all data from the table are gone. It would be great to save this data permanently, and simply add new data to the existing table after an application restart.
What's the best way to achieve this?
In my mind, it would the best way to overwrite the existing Excel file with the new work (old and new data from the table), because it would be easy to install the tool on a new PC and simply import the Excel file to have all data there. I don't have access to a web server, so I think a local Excel file would be better than a php solution.
Thank you.
<table class="table" id="tblData" >
<tr>
<th>Teilenummer</th>
<th>Hersteller</th>
<th>Beschreibung</th>
</tr>
</table>
This is the actual table markup.

Your question has two parts, it seems to me.
data representation and manipulation
data persistence
For #1, I'd suggest taking a look at Tabulator, in particular its methods of importing and exporting data. In my projects, I use the JSON format with Tabulator and save the data locally so it persists between sessions.
So for #2, how and where to save the data? Electron has built-in methods for getting the paths to common user directories. See app.getPath(name). Since it sounds like you have just one file to save, which does not need to be directly accessible to the user, appData is probably a good place to store it.
As for the "how" to store it – you can just write a file to that path using Node fs, though I like fs-jetpack too. Tabulator can save data as well.
Another way to store data is with electron-store. It works very well, though I've only used it with small amounts of data.
So the gist is that when your app starts, it loads the data and when the app quits, it saves the data, along with any changes which have been made, though I'd suggest saving after every change.
So, there are lots of options depending on your needs.

Related

How to modify Access DB File which is in sharepoint Document Library

I am having accdb file(Ms access DB file) in sharepoint Document Library. I want edit the file in browser or without downloading the file to the local.
I am able to view the file but not able to Edit it.
Need help
Access doesn’t really work this way. You can store the data tables in Sharepoint, but you still need the local access file to interact with it. You can link to data tables in Sharepoint. Instead of creating a brand new table, you import the data source.
Microsoft does have a newish program out now called PowerApps that may help you accomplish something closer to what you’re describing.

How to get live data from excel to a webpage?

I have an excel which gets live data from a thrid party. I want to display that live data from excel in a webpage. Can someone guide on how to do it?
Any inputs appreciate
Thank you
Your server will need to make a query of the same source. The following is one of dozens of ways to do this.
Set up a cron job to to the following:
1:Use curl to pull the data.
2:Use an awk program to reformat the data to a data file as a table with html table markup.
3:Concatenate a header file, your data file, and a trailer file to make a valid html file that you want.
4:Store that file on the web server.
If you want to do live updates rather than have the user reload the file you either have to push the data, or write JavaScript to reload the webpage element at intervals.
This is an excellent project. Learn this and you’ll have a big step up in your web building skills.

Is it a good idea to manage database with csv files?

I'm working on a feature that imports users into a MySQL database.
The initial goal of this feature was to add new users from CSV files.
Gradually my client wants more of this tool. Indeed, if the CSV file contains a row with an already existed user, the data will be updated (the feature erases the old data with the new). So we implement it.
After that, he wants to update users (i.e. remove data, add data et cetera) but he already has a man/machine interface to do that.
I feel we're going in the wrong way.
What do you think about this ? Is it a good idea to manage database with csv files ?
I can see no problem using CSV to do that. You need to define a clear file format which specify object type and action, like for example :
<object type>;<action>;<value1>;<value2>;etc…
So you can have
user;add;Bob;Stone;fr
then
user;update;Bob;Stone;uk
then
user;del;Bob;Stone
etc…

"POST" form data to XLS/CSV

So I'm trying to essentially "POST" data from a form in an offline webpage, to an Excel spreadsheet, or CSV, or even just a TXT file. Now I have seen this to be possible using ActiveX in Internet Explorer, however, the methods I saw were pretty particular to the user's code, so I got a bit lost in translation being a beginner. Also some recommended using an offline database using JS, but I'm not sure where to begin with that.
Can anyone offer some insight on this? Is it possible? What would be the best route to take?
There are many ways to accomplish this. The best solution will be the one that suits your specific requirements. Obviously, creating a text/csv file is easier than creating an xls. That said, the basic psuedo code is as follows:
Collect form data
Create (in-memory or temporary) file from collected form data.
Return file as download to client, or just save to some location, OR (best option) insert a row into a database.

Streaming CSV to browser

Busy building a website for a client using classic ASP (It will reside on an old server) which is going to be used internally only.
The admin is able to view a paginated table of data and export this to CSV. This works fine when I save the CSV data to a CSV file but I have now been asked to try avoid the creation of the file if possibly and create the CSV in memory without the need for a file.
I have my doubts that this is possible but might be completely wrong. Is there anyway to send the CSV data to the browser such that it will open in Excel rather than having to create a CSV file and link to it as I am currently doing ?
TIA
John
Response.ContentType = "text/csv" will help you here. In the past I've paired that with a rewrite rule so that the URL is something like foo.com/example.csv but there are plenty of other ideas to be found in the following question: Response Content type as CSV