Hi,
I have to create *.xls (or *.csv) with multiple tabs.
The program is in the loop and every time the loop runs it should create a new tab. Can any one help me with this. (I want to code it with out using PYExcelerator - I tried using that function but it throws an error saying "ImportError: No module named pyExcelerator" can some body help me with this too... resolving the error.)

Thanks,
Supriya

Dani AI

Generated

Given the ImportError shown by and the install hint from , the most likely causes are a mismatch between the Python interpreter used to run the script and the interpreter where the package was installed, the package not being visible on Python's import path, or a local filename shadowing the package. Useful, non-invasive checks and fixes are listed below.

Run these from the same command prompt that will launch the script to confirm which Python is running and what paths it searches:

python -c "import sys, pprint; pprint.pprint(sys.path); print('exe:', sys.executable); print('ver:', sys.version)"
python -c "import pkgutil; print('loader:', pkgutil.find_loader('pyExcelerator'))"

If the loader is None or the site-packages directory is not on sys.path, install the package with the pip tied to that interpreter so installation lands in the same environment:

python -m pip install pyExcelerator

If pip reports the package as installed but import still fails, check for naming collisions (a script or folder named similarly to the module in the current working directory will interfere), make sure the package isn't left as a zipped egg that needs extracting, and restart the interpreter/console after installing.

As an alternative to troubleshooting pyExcelerator, consider libraries that are easier to install and actively maintained for writing Excel files (examples: xlwt for .xls, openpyxl or XlsxWriter for .xlsx). An xlwt-style pattern for multiple sheets is straightforward:

from xlwt import Workbook
wb = Workbook()
s1 = wb.add_sheet('Sheet1')
s2 = wb.add_sheet('Sheet2')
s1.write(0,0,'example')
wb.save('output.xls')

These checks isolate whether the problem is environment/installation related (most common) or code-related, and the alternative libraries provide a quick path around persistent install issues.

Recommended Answers

All 5 Replies

You will need to download and install pyExcelerator as it is not distributed with the standard Python.
Link: Py Package

You cannot create a csv file with multiple sheets (tabs), as the format does not allow it.

You will need to download and install pyExcelerator as it is not distributed with the standard Python.
Link: Py Package

You cannot create a csv file with multiple sheets (tabs), as the format does not allow it.

Hi,
Thanks for the reply. Can u please tell me where to place the downloaded file?
Thanks

If you don't know how to build python packages, simply extract the pyExcelerator directory and place it in your Python site-packages folder... on Windows it will be: C:\PythonXX\Lib\site-packages .

If you don't know how to build python packages, simply extract the pyExcelerator directory and place it in your Python site-packages folder... on Windows it will be: C:\PythonXX\Lib\site-packages .

Thanks. I tried what u said. It still gives me this error

Traceback (most recent call last):
File "C:\Documents and Settings\xlspyexcel", line 1, in ?
from pyExcelerator import *
ImportError: No module named pyExcelerator

and this is the program I am running

from pyExcelerator import *
wb = Workbook()
ws0 = wb.add_sheet('0')

for x in range(10):
for y in range(10):
# writing to a specific x,y
ws0.write(x,y,"this is cell %s, %s" % (x,y))

wb.save('output.xls')

Please let me know what is wrong (I copied this program from internet)

First try opening an interpreter and just type in import pyExcelerator . That will tell you if you copied the directory to the right location.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.