-->
Welcome, Guest
Username: Password: Remember me
Check that your potential issue isn't already confirmed and fixed in the recent releases. A summary of all changes can be found in the Dolibarr Changelogs

TOPIC: Corrupt Excel Import File

Corrupt Excel Import File 2 months 1 week ago #34523

  • RS Automation
  • RS Automation's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 11
  • Thank you received: 1
  • Karma: 0
Hello,

In the Import Assistance module any (Products, Third Parties, etc) of the excel import template files I try to download will not open due to the following error:
"Excel cannot open the file 'Example_of_import_file_produit_1.xlsx' because the file format of file extension is not valid. Verify that the file had not been corrupted and that the file extension matches the format of the file"

If I open the file in a text editor I see the following:
<br />
<b>Warning</b>: tempnam(): open_basedir restriction in effect. File(C:\WINDOWS\TEMP) is not within the allowed path(s): (c:/dolibarr) in <b>C:\dolibarr\www\dolibarr\htdocs\core\modules\import\import_xlsx.modules.php</b> on line <b>182</b><br />
<br />
<b>Warning</b>: ZipArchive::open(): Empty string as source in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>239</b><br />
<br />
<b>Warning</b>: ZipArchive::open(): Empty string as source in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>240</b><br />
<br />
<b>Fatal error</b>: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not open for writing.' in C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php:241
Stack trace:
#0 C:\dolibarr\www\dolibarr\htdocs\core\modules\import\import_xlsx.modules.php(184): PHPExcel_Writer_Excel2007->save(false)
#1 C:\dolibarr\www\dolibarr\htdocs\imports\class\import.class.php(217): ImportXlsx->write_footer_example(Object(Translate))
#2 C:\dolibarr\www\dolibarr\htdocs\imports\emptyexample.php(88): Import->build_example_file('xlsx', Array, Array, 'produit_1')
#3 {main}
thrown in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>241</b><br />

This is a fresh installation of Dolibarr.

The CSV template downloads and opens fine.

Thanks in advance.
The administrator has disabled public write access.

Corrupt Excel Import File 2 months 1 week ago #34527

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Trying to make the source open.
  • Posts: 649
  • Thank you received: 92
  • Karma: 12
Hello

Thanks for posting. You have posted your issue in the Bugs on a stable version section.

Kindly post (here) your Dolibarr setup environment as suggested in https://www.dolibarr.org/forum/2-this-forum/28209-post-guidelines. This will greatly help the community in assisting you where possible.
The administrator has disabled public write access.

Corrupt Excel Import File 2 months 1 week ago #34540

  • RS Automation
  • RS Automation's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 11
  • Thank you received: 1
  • Karma: 0

DOLIBARR ENVIRONMENT
- Version: 8.0.1
- Operating System: Microsoft Windows 10 Pro for Workstations
- Web Server: Apache/2.4.9 (Win32)
- PHP: PHP 5.5.12
- Database: MySQL 5.0.45
- URL(s): http://dolibarr/dolibarr/imports/emptyexample.php?format=xlsx&datatoimport=adherent_1&excludefirstline=1&separator=%2C&enclosure=%22
The administrator has disabled public write access.

Corrupt Excel Import File 2 months 1 week ago #34529

  • 8clicks
  • 8clicks's Avatar
  • OFFLINE
  • Senior
  • Posts: 47
  • Thank you received: 7
  • Karma: 2
Hi,
you can check your read/write permission for the file. Make sure it's enable for read/write

C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php
The administrator has disabled public write access.

Corrupt Excel Import File 2 months 1 week ago #34541

  • RS Automation
  • RS Automation's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 11
  • Thank you received: 1
  • Karma: 0
8clicks wrote:
Hi,
you can check your read/write permission for the file. Make sure it's enable for read/write

C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php

Thank you for the suggestion. The file was originally set to read only. But changing to read / write has not resolved the issue.
The administrator has disabled public write access.

Corrupt Excel Import File 2 months 1 week ago #34545

  • ksar
  • ksar's Avatar
  • NOW ONLINE
  • Senior
  • Posts: 73
  • Thank you received: 32
  • Karma: 4
Hi,

The problem is for the import, your serveur php need to create a temporary file.
He tries to do it but your configuration does not allow to create a file in that folder : open_basedir restriction in effect. File(C:\WINDOWS\TEMP)

Need to check the php configuration.
The administrator has disabled public write access.

Corrupt Excel Import File 1 month 2 weeks ago #34901

  • RS Automation
  • RS Automation's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 11
  • Thank you received: 1
  • Karma: 0
This issue remains unresolved.

While reviewing Projects - Overview, under "List of time consumed on tasks of project", I have also encountered another similar error:
Warning: is_dir(): open_basedir restriction in effect. File(/TK1810-0001) is not within the allowed path(s): (c:/dolibarr) in C:\dolibarr\www\dolibarr\htdocs\core\lib\files.lib.php on line 101

Line 101 within "files.lib.php" reads as follows:
if (! is_dir($newpath)) return array();

It seems to me there is a privilege not set correctly somewhere that is preventing Dolibarr from writing necessary files.
The administrator has disabled public write access.

Corrupt Excel Import File 1 month 2 weeks ago #34910

  • ksar
  • ksar's Avatar
  • NOW ONLINE
  • Senior
  • Posts: 73
  • Thank you received: 32
  • Karma: 4
Hi,

Do you read what I have put above ?
You have a problem of temporary directory in php configuration

Open the php.ini and check :

Find the directive upload_tmp_dir: uncomment the line and change its value to a required path. In this example it is "/var/tmp":

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = /var/tmp

Additionally for PHP versions 5.5 and greater, find the directive sys_temp_dir: uncomment the line and change its value to a required path. In this example, it is "/var/tmp":

; Directory where the temporary files should be placed.
; Defaults to the system default (see sys_get_temp_dir)
sys_temp_dir = "/var/tmp"

Now, add the new path (in our example it is "/var/tmp") to open_basedir of all domains, so that PHP scripts can access this directory. Use this KB article for assistance.
Note: The record to be added to the php.txt file should be:

open_basedir = {WEBSPACEROOT}{/}{:}{TMP}{/}:/var/tmp
The administrator has disabled public write access.
Time to create page: 0.070 seconds