Okay
  Public Ticket #2737141
Import csv/excel to existing datatable.
Closed

Comments

  • Vince Louie started the conversation

    Hi Good Day.

    May I know if it is possible with wpdatatables to be able to allow specific users to upload their csv or excel records to existing wpDatatables instead of typing it one by one. And also is it possible that when user import the file, if there is a record with the same details, it should not be added again to avoid duplicates. Thank you so much and appreciate you feedback.

  •  2,499
    Aleksandar replied

    Hello Vince

    Thank you for your interest in the plugin.

    You can use Excel files in two ways to create wpDataTables:

    1. Create a table linked to an existing Excel file, in which case you get to select the file (upload it) that'll be used to pull the data. This file will be stored in ../wp-content/uploads/YEAR/MONTH/ folder. The file on that location can be changed, but the structure can't. So, you would not be able to add, remove, reorder or rename columns in that file, or the wpDataTable will break. Also, you would not be able to edit the wpDataTable generated from this file.

    2. Create a table by importing the Excel file. In this case, the source file is read, and a manual table is created. So, the generated table reads the source only once, and after that there are no relations between it and the wpDataTable. You would be able to edit the table, but the changes wouldn't be seen in the source file.

    So, with #1 - you would need to replace the file in the uploads folder, and it can't be done by front-end users.

    With #2 - you would be able to add new data to the table if you enable the "Excel-like" editor, and then copy and paste a range of rows and columns.

    Another way would be to save new values of the Excel file as CSV, and then import that file to the wp_wpdatatable_# table in the database - the table that's generated when an external file is imported.

    The plugin doesn't have any features that would look for existing data, and disable editing if there already exists an entry like that. You can, however edit a field in the database, adding a unique constraint, like this:

    ALTER TABLE myTableName ADD CONSTRAINT UQ_MyTable_Name UNIQUE (columnName)
    

    And it will not allow anyone to add the same name if it already exists in the table.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables