Welcome Guest, Not a member yet? Register   Sign In
How to read data from Excel & insert into table using CI?
#11

[eluser]sparky672[/eluser]
[quote author="mikemiller" date="1409680679"]You could try PHPExcel - very capable library that can be used to read excel files (including xlsx)

https://phpexcel.codeplex.com[/quote]

Thank-you, I was looking at that one too.

I just need a simple function that displays an uploaded Excel sheet to the screen. I don't need to create or write Excel files or save anything to the database, so many of these plugins seem like overkill with their features.

I found an obsolete library that had a "dump" function (for just displaying the Excel file on the screen), but like I said, it's obsolete, and the download link for the "updated" version on the corresponding CI wiki page is dead.

Do I just dynamically create the table every time a user views this data, or do I create a static HTML file whenever a new Excel file is uploaded, or do I save it to the database and dynamically create the view from that... is just one issue I'm contemplating and I suppose depends on the capabilities of the library. Can the library create the HTML tables accurately or do I need to write my own function to parse it... is another issue I'm investigating.

I need a library that can take an Excel file, which contains a single sheet with multiple tables, and accurately render it on the screen. It's a Excel file the website owner will be uploading so I can dictate some of the requirements and instruct them on the proper format if needed.

I'm looking at this one too...

http://faisalman.github.io/simple-excel-php/
#12

[eluser]Flemming[/eluser]
I would dynamically create the data to display each time the page loads and see how that works for you - are you expecting a very high number of page views?

Also, before you get bogged down in libraries, CroNiX's advice was good - why not look at php's built-in CSV functions:

http://php.net/manual/en/function.fgetcsv.php

and in particular, the example by myrddin at myrddin dot myrddin - looks like a good place to start! :-)
#13

[eluser]sparky672[/eluser]
Thanks for the advice. I'll see where it takes me.

[quote author="Flemming" date="1409691754"]the example by myrddin at myrddin dot myrddin - looks like a good place to start! :-)[/quote]

I'll check it out.
#14

[eluser]Flemming[/eluser]
Follow the link to php.net and then search the page for "myrddin at myrddin dot myrddin" and you'll see what I meant! :-)
#15

[eluser]sparky672[/eluser]
[quote author="Flemming" date="1409692184"]Follow the link to php.net and then search the page for "myrddin at myrddin dot myrddin" and you'll see what I meant! :-)[/quote]

I edited while you replied. Yes, I finally figured that out. Thank-you!

The spreadsheet is pretty complex (multiple tables with different number of columns in each), but if I can get client to save as a CSV file, then I'll see if the fgetcsv method works before trying one of the Excel libraries.
#16

[eluser]Flemming[/eluser]
Good luck :-)

Let us know how you get on!




Theme © iAndrew 2016 - Forum software by © MyBB