-1

I am currently working on a website, and would like to display data from an excel sheet on it.

Excel sheet format:

  • Each row contains an 'item', and each column contains properties of that instance of the item.

What I'm trying to do:

  • I'm trying to display an item (row in excel sheet of columns that I pick) one at a time to a user from the sheet, and upon clicking left or right buttons, it goes to the next or prev item.

  • I'd like to only display certain properties, so I'm not using all cols in spreadsheet(so if a row had an image in col A, a name in col B, and a summary in Col 3, etc)

So, my question: How should I go about implementing this into my website?

  • I have read its possible use javscript to import excel data and manipulate it (so I guess I'd instantiate an object which contains the data I need from the sheet and display it on the website, each time the user clicks I would just replace the object)
  • I also read about importing the excel sheet into a database (mySQL), and then getting the data from the database and instantiating the object that way with PHP. I haven't learned SQL yet, but I read it's not too complex for simple things and I do plan on learning it regardless.

Thanks for any suggestions!

AlexP
  • 7
  • 1
  • 2
  • How many rows/columns in the sheet? How often will the contents change? Are you dependent on formulas in the sheet, or just raw values? – Alex Howansky Aug 18 '21 at 17:36
  • Just raw values (text and images), no formulas, the contents will not change often. The sheet has ~60 rows and I'd like to display properties from 4 out of the available 11 cols. – AlexP Aug 18 '21 at 17:39
  • 1
    Generally, I'd say, don't bother with XLSX, just export to CSV and then use `fgetcsv()` to read it. The requirement of images makes that tricky though. If that's a showstopper, then I'd use the [PHPSpreadsheet](https://packagist.org/packages/phpoffice/phpspreadsheet) package. It's not worth messing with databases for 60 rows. In either case, I'd do it in PHP (server side) -- if you do it with JS (client side) then you'll have to make your spreadsheet available to the public. – Alex Howansky Aug 18 '21 at 17:44

1 Answers1

1

This thread may help you:

How to parse Excel (XLS) file in Javascript/HTML5

Personally, I hate working with excel sheets and convert them to csv whenever I can. Then parse the csv and convert the rows to JSON format.