mos
mos

Reputation: 121

ModuleNotFoundError: No module named 'xlswriter'

Everytime I run the code I get this error although I tested it with another code and I found that xlswriter is installed

I have tried a sample Hello world with import xls writer code and it worked and did not give me the same error

##import csv
import xlswriter
##with open(r'C:\Users\mosta\Downloads\ForlanChemicals.csv', 'r') as csvfile:
  ##  spamreader = csv.reader(csvfile)
 ##   newlist= list(spamreader)
    ##print(newlist)

workbook= xlswriter.Workbook('Test1.xlsx')
worksheet= workbook.add_worksheet()

worksheet.set_column('A:T', 12)
worksheet.set_row(3, 30)
worksheet.set_row(6, 30)
worksheet.set_row(7, 30)


# Create a format to use in the merged range.
merge_format = workbook.add_format({
    'bold': 1,
    'border': 1,
    'align': 'center',
    'valign': 'bottom',
    'fg_color': 'orange'})


# Merge 3 cells.
worksheet.merge_range('A1:D1', 'Contact Personal Information', merge_format)

merge_format2 = workbook.add_format({
        'bold': 1,
        'border': 1,
        'align': 'center',
        'valign': 'bottom',
        'fg_color': 'green'})

worksheet.merge_range('G1:L1', 'Work Contact Information', merge_format2)

merge_format3 = workbook.add_format({
        'bold': 1,
        'border': 1,
        'align': 'center',
        'valign': 'bottom',
        'fg_color': 'blue'})

worksheet.merge_range('M1:R1', 'Personal Contact Information', merge_format3)

workbook.close()

Ignore the read part which I am commenting out but I am trying to write a new xlsx file while formatting the chosen rows

Upvotes: 0

Views: 661

Answers (1)

Adrian
Adrian

Reputation: 177

It appears that you are simply missing the second x in xlsxwriter. This would require the following changes:

import xlsxwriter

...

workbook= xlsxwriter.Workbook('Test1.xlsx')

Upvotes: 1

Related Questions