WordPress.org

Ready to get started?Download WordPress

Forums

Pulling data from Excel file (8 posts)

  1. Ruge
    Member
    Posted 4 years ago #

    Hi folks!

    I am currently working on a phone company website. My client has requested a series of pages to tabulate the price rates. However, he would like users to be able to sort data by Country (click A,B,C etc) and then data will be displayed for those countries.

    My first thought was to create 26 pages, however I believe there should be an easier way to do it. Is there any way I can create a page on WordPress that could pull data from an Excel file (and display data based on the letter selected?)

    I know this sounds like a long shot, but I am aiming for this type of effect: http://qlinkq.com.au/lankarates.php

    Thank you in advance :)

  2. stvwlf
    Member
    Posted 4 years ago #

    Typically you load the data from the spreadsheet in a MySQL database table and run SQL queries using PHP on each request to grab the relevant info from the database. That is how the example page you linked to is doing it. You can import the data from the Excel sheet into the database table by exporting from Excel as a CSV file.

    If there aren't hundreds of entries it can also be done by displaying the full results for all the countries on a single page, and then use a Javascript accordion (hiding) technique to hide everything except for that which the user is trying to see. The javascript opens and hides sections depending on what the user clicks on.

  3. Ruge
    Member
    Posted 4 years ago #

    Interesting. Im pretty much a designer, not a developer, so do you know any resources that I could look into? Would be greatly appreciated!

  4. stvwlf
    Member
    Posted 4 years ago #

    Hi - Not sure where to direct you. You as the designer would create the HTML table to display the stored contents, which would be retrieved by PHP code that then populated the table. It requires PHP and MySQL programming skills. Best bet is Google for tutorials on database programming.

    For the javascript accordion technique, Google for jQuery accordion.

  5. boyplunder
    Member
    Posted 4 years ago #

    Try this if it isn't to be dynamic.
    Save the excel sheet to a web page. Open it in a web editor or TextEdit, copy the table you get, and paste it into an html new post. I use this method on a football blog I have.

    Always best to style it up in the web editor, not the post.

  6. Ruge
    Member
    Posted 4 years ago #

    Hmm, well, it has to be somewhat dynamic.

    Here's my connundrum, I could easily copy a table and paste it into wordpress and it looks fine. However, lets say the letter B.... It has 330 entries. If i tried to copy that into WordPress my PC hangs for quite somet ime.....

    Ideally I wanted to be able to set up a script that would read a CSV file and display the table in the post the same way copy and pasting it would....

  7. stvwlf
    Member
    Posted 4 years ago #

    You do not want to paste all of that into a WP post. You are likely to have issues with the editor reformatting your code in ways you don't want.

    If the data in the tables is not updating often, a half way point between doing it in SQL and pasting it into WP posts could be:

    Save 26 CSV files, one for each letter.
    Create one WordPress PAGE, not 26 posts.
    Create a custom page template that is used with that one WordPress page. This would be custom PHP that read the CSV file for the letter being processed and generated the table dynamically using the data in the CSV file as the table contents.

    When someone clicked on the letter N, the URL would include ?letter=N at the end of the URL. The PHP script would read that and select the CSV file for the letter N and populate the table with its contents.

    Whenever the entries for a CSV file letter change you upload a revised version of that CSV file to the server and the changes are reflected on the site.

    If the data can change once a day or once a week, this is not a good approach as its too much work. If it changes every month or a few times a year it becomes workable. The advantage of this approach is you don't have to deal with SQL and custom tables. The PHP script to generate the table from the CSV file is not very complicated, and as a designer you would apply the same styling to the table that you do in a straight HTML design. The PHP would generate the necessary class names that you attach styling to.

    The Codes page for custom page templates is here
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
    A tutorial from Google:
    http://www.expand2web.com/blog/custom-page-template-wordpress/

    The WP page would have no page content. It adds the Rates option to the site Nav and serves as a shell to let the PHP in the custom template do its work.

  8. JamesBB
    Member
    Posted 4 years ago #

    This plugin can import Excel tables and data can also be sorted out.
    http://wordpress.org/extend/plugins/wp-table-reloaded/
    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Topic