views:

50

answers:

2

Hey Guys and Gals,

I have what I consider a bit of a tricky question. I am currently working on quite a large spread sheet (266 rows aith 70 coloumns and its only going to get bigger) that is a database of sorts and I want to remove it from Excel and put it on to an intranet page. I am currently writing it in a combination of HTML and Javascript for functionality, but it is becoming very hard to ensure that the data is in the right place. I am wondering if there is a possible way of being able to save the Excel spreadsheet into a certain format (like CSV or XML) and then write a program (for on a HTML page) that would display all of the infomation in a table automatically? is this even possible?

Unfortunatly i do not have access to a server to be able help with this, it all needs to be able to be coded in the page itself.

Thankyou for all your input Guys and Gals

+1  A: 

Based on your comment, a normalized database for this type of thing would look like this:

table `workers`
- id
- name
- ...

table `trainings`
- id
- title
- description
- ...

table `workers_in_training`
- worker_id
- training_id

This allows you to create a logical matrix as well without the need to change the schema (keep adding columns) for each new training/worker. Of course, this realistically requires a database server of some sort and knowledge in a server side programming language (PHP, Python, Ruby, C#, anything). If you don't have that, an Access database/app may be an acceptable compromise. Doing it all in Javascript is certainly interesting, but is an idea you should abandon as early as possible.

deceze
+1 - Exactly what I was thinking!
Jason Whitehorn
@deceze thanks for you comments on this questions. seeing as i do not have access to a server as such i have decided to abandon the idea of have some form of automation for this page and to just cretae the long and hard, but tried and semi reliable, way of creating a HTML table on my web page and hand filling it.
Jason Maher
A: 

Given your constraints, I would save the Excel spreadsheet as a CSV and put it in the same location as your HTML file, then use AJAX to fetch the contents of the CSV and dynamically generate a HTML table based on the contents.

Look here for how to fetch a URL's contents using AJAX (jQuery library): http://api.jquery.com/jQuery.get/

After fetching the URL content, you will have the CSV as a big string in a JavaScript variable. I'll let you have the fun of figuring out how to parse it :-)

Once you know how to parse your CSV string to recognise rows and columns, look here for how to generate HTML table dynamically using jQuery library: http://stackoverflow.com/questions/103489/building-an-html-table-on-the-fly-using-jquery

Yoshi
The real problem comes when you try to persist any changes though.
deceze
I assumed he wanted to just render the contents and not edit it. What a hopeless situation if the client JavaScript has to change the spreadsheet contents!
Yoshi
Yoshi, right you are, i was wanting to render the contents. the client side of this projct is to be a read only Intranet page that only i have access to the info to change. i was not looking for the Javascript to change the spreadsheet contents.
Jason Maher