When I upload excel file(.xls) on the 'Data upload form' page(the selected option of 'Desired operation' is 'Insert into existing table') ,it report the warning 'Selected file and table are incopatible. The table has 2 columns, and the file 1 columns', but actually the columns of the excel file(.xls) is matched with the table's, and I have copy the file 'excel_reader2.inc' to the importer directory according to 'README.TXT', so how can I solve this question? Thanks very much!

CommentFileSizeAuthor
#2 importer_report.zip16.45 KBfister_drupal

Comments

kartelusm’s picture

Assigned: fister_drupal » kartelusm

I wasn't able to reproduce a bug. Would you be able to send me a file and an sql export of the table, so I can try with them?

fister_drupal’s picture

StatusFileSize
new16.45 KB

Thanks for your immediate help very much, I have upload the table's sql file and excel file as attach, and it only report the warning with the selected option 'Insert into existing table' of 'Desired operation' when upload file to import.

kartelusm’s picture

Hi, I've tried it with your data on MySQL DB (the only thing I changed were the names of the columns in the xls, but that has absolutely no relevance) and the module added the new row without a problem. I'm guessing that it has maybe something to do with the database you're using or the version of it. The relevant code that counts the number of columns (minus PK) in the table is this:

/**
 * Utility function - returns all the columns
 * from the db table forwarded in the $form_state
 * @param $form_state
 */
function _importer_table_description($form_state) {
  $column_names = array();
  $tablename = isset($form_state['values']['table_list']) ? $form_state['values']['table_list'] : $form_state['storage']['values']['_importer_form_start']['table_list'];
  $tablename = db_escape_table($tablename);
  if (db_table_exists($tablename)) {
    $results = db_query("show columns from {" . $tablename . "}");
    $i = 0;
    while ($result = db_fetch_object($results)) {
      if ($result->Key !== "PRI") {
        $column_names[$i]['name'] = $result->Field;
        $column_names[$i]['type'] = $result->Type;
        $i++;
      }
    }
  }
  return $column_names;
}

If this is incompatible with your database, maybe that's the problem. You can tweak it yourself (and share a patch for me to include) or alternatively tell me what are you using as a database so I can look into it.

fister_drupal’s picture

Hi, I also use MySQL as database, and the 'importer' module detect the columns of DB table correctly, so I think the question is in the 'excel_reader2.inc', and it report wrong columns of excel file when I select the 'Insert into existing table' option on my drupal site. I will check the code of 'excel_reader2.inc', Thanks again!

rupertj’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.