excel

trying to add sparklines to multiple rows with xlsxwriter

trying to add sparklines to multiple rows with xlsxwriter Question: Im trying to add sparklines into a column with xlsxwriter to my excel. I got it to work with just one row but i wanted to ask how i would do this for multiple rows without writing out multiple lines of code for each row. …

Total answers: 1

How to represent the data of an excel file into a directed graph? Python

How to represent the data of an excel file into a directed graph? Python Question: I have downloaded California road network dataset from Stanford Network Analysis Project. The data is a text file which can be converted to an excel file with two columns. The first is for the start nodes, and the second column …

Total answers: 2

ExcelWriter using openpyxl engine ignoring date_format parameter

ExcelWriter using openpyxl engine ignoring date_format parameter Question: I have read quite a few answers on this, but when I run my code I don’t get the same result. I am using pandas 2.0.0 and openpyxl 3.1.2 on Python 3.9 This is a reduced example of my issue, which is that I can’t get the …

Total answers: 2

Error: AttributeError: 'str' object has no attribute 'row'

Error: AttributeError: 'str' object has no attribute 'row' Question: I have code: def add_to_database(object_name, value): workbook = openpyxl.load_workbook(DATABASE_FILE) worksheet = workbook[DATABASE_SHEET] object_row = None for row in worksheet.iter_rows(min_row = 1, max_row = worksheet.max_row + 1, values_only = True): if row[0] == object_name: object_row = row break if object_row: worksheet.cell(row = object_row[0].row, column = 2).value += …

Total answers: 1

file module issues with excel format

File module issues with excel format Question: My goal is to write result into single excel file, here is simple code that I tried: import numpy_financial as npf Present = 2000 period = 20 rate = 0.12 pmt = abs(npf.pmt(rate/12,period*12,Present)) print(pmt) import csv file = open("Result.xlsx",’w’) file = csv.writer(file) file.writerow([pmt]) As an outcome, Result.xlsx was …

Total answers: 1

Export styled dataframe to Excel (background color)

Export styled dataframe to Excel (background color) Question: I’m looking to generate an excel file from styled dataframes. Specifically I want to keep the background colors of cells. I can generate an excel file with df.to_excel() or df.style.to_excel(), but the background color disappears along the way. Is there any way to keep the background color? …

Total answers: 1

Openpyxl: Excel file created is not showing validation errors or prompt message

Openpyxl: Excel file created is not showing validation errors or prompt message Question: I am generating a excel file using openpyxl and adding a list as a validation. I am successfully able to create the drop down list but when I add invalid data in the validated column it shows no error or prompt even …

Total answers: 1

python write a list to multiple columns in excel

python write a list to multiple columns in excel Question: I am trying to write many columns in excel. I have a list let’s say as below list1=[1,2,3,4,5] the other list will be like list2=[‘a’,’b’,’c’] I will have many different sized(length) lists which is why I cannot create dataframe in pandas and write it. list3=[‘1a’,’2b’,’3c’,’4d’] …

Total answers: 1

Xlsm file Python

Xlsm file Python Question: I want to open an .xlsm file with openpyxl library. When I tried to open it, it gives me the IndexError: index out of range. I also observed if I delete all the hidden worksheets in the file before running the code it will be OK. Can you help me? Because …

Total answers: 2