openpyxl

python openpyxl excel file reading error

故事扮演 提交于 2019-12-12 01:15:41
问题 I am writing a xlsm(macro enabled excel) file with openpyxl.load_workbook. but sometimes it is giving the following error Sample code in script: from openpyxl import load_workbook wb =load_workbook(filename = 'F:\Reports\asdf.xlsm') Error Details File "C:\Python27\lib\site-packages\openpyxl\worksheet\header_footer.py", line 209 warn("""Cannot parse header or footer so it will be ignored""") UserWarning: Cannot parse header or footer so it will be ignored 来源: https://stackoverflow.com

How to extract a particular row value on inputting value of a particular row

允我心安 提交于 2019-12-11 23:13:57
问题 I want to make a GUI program that inputs the value of a column the program must go to the row where the inputted value is equal to the row value and display the particular row value in a text box but I am clueless on how to do this. I tried using while loop to do it so it will search the whole excel file to check whether value of inputted data is equal to the data in the textbox but it did not go properly. I am using python 3.7.0 using anaconda. from tkinter import * import openpyxl a = Tk()

Update values of multiple Excel workbooks with openpyxl

独自空忆成欢 提交于 2019-12-11 19:49:24
问题 I have a lot of Excel worksheets with a lot of same values that I should update with new values periodically so I googled and found Automate the Boring Stuff. Chapter 12 – Working with Excel Spreadsheets. My workbooks have a header from row 1 to 6 with a couple of images and some cells are merged. I followed the Chapter 12 and found a simple script that should do what I need, this is what I came up with import openpyxl from PIL import * excelFile = openpyxl.load_workbook('V23 R.0.xlsx') sheet

openpyxl basic search

五迷三道 提交于 2019-12-11 18:06:33
问题 I am trying to search an excel document and if the name of the mp3 file is matched in the excel document, It prints out the row the instance of the name is found on. this is what I have: from mutagen.easyid3 import EasyID3 from openpyxl import load_workbook import glob import re import os for name in glob.glob('*.mp3'): audio = EasyID3(name) wb = load_workbook('xl.xlsx') sh = wb.get_sheet_by_name('Russian') for row in sh: if row.value == name: print row.number 回答1: First of all you are

Writing a list to new excel xlsx with dataframes

浪尽此生 提交于 2019-12-11 17:42:06
问题 I am having some trouble finding the best way to write a list to a loaded excel sheet and then saving the result as an xlsx. What I want my code to do is to take the lists that I have created and put them in specific columns of the loaded workbook. I think there is probably an easier way to do this using dataframes, but I do not know how. Ideally, I would like to save the formatting of the loaded workbook. col_test = [1L, 2L, 3L, 4L, 5L] My code is this import xlrt from xlrd import open

Adding labels to ScatterChart in openpyxl

巧了我就是萌 提交于 2019-12-11 17:35:33
问题 I have wrote this simple code to test things out for a more complicated one: import sys from openpyxl import load_workbook from openpyxl.chart import Reference, ScatterChart, Series from openpyxl.chart.label import DataLabel, DataLabelList from openpyxl.chart.marker import Marker from openpyxl.chart.shapes import GraphicalProperties from openpyxl.drawing.colors import ColorChoice wb = load_workbook(sys.argv[1]) for ws in wb: chart = ScatterChart(scatterStyle='smoothMarker') for x in range(2,

Sort data in a list to columns for xlsx files

你说的曾经没有我的故事 提交于 2019-12-11 17:35:22
问题 I have a list that looks something like this. (The data is from several xlsx files): [['A B 10', 2, 'A B 10', 3, 1, AC], ['A B 104', 3, 'A B 104', 2, -1, 'AC']] [['D B 126', 3, 'D B 126', 2, -1, 'EFG 1'], ['D B 15', 3, 'D B 15', 2, -1, 'EFG 1'] [] [] [['D B 544', 2, 'D B 544', 1, -1, 'EFG 11'], ['D B 152', 3, 'D B 152', 2, -1, 'EFG 11'], ['D B 682', 3, 'D B 682', 2, -1, 'EFG 11'] I want to put this information into a new xlsx file, but first I need to sort the data into rows and columns. I

openpyxl - Unable to access excel file with openpyxl when it is open but works fine when it is closed

狂风中的少年 提交于 2019-12-11 17:28:54
问题 I've been making this python script with openpyxl on a MAC. I was able to have an open excel workbook, modify something on it, save it, keep it open and run the script. When I switched to windows 10, it seems that I can't modify it, save it, keep it open, and run the script. I keep getting an [ERRNO 13] Permission denied error. I tried to remove the read only mode on the folder I'm working on, I have all permissions on the computer, I clearly specified the save directory of my excel workbooks

write to an open exceldocument

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 16:11:08
问题 I'm working on a project which I am going to write values to a exceldocument. I can write values to excel but I want to write the values to excel with the document open. If i have the doc open when trying to write to it i get an error message. Here is my code I'm currently using. #Write to excel from openpyxl import Workbook import datetime wb = Workbook() ws = wb.active ws['C3'] = 1337 ws['A1'] = datetime.datetime.now() ws['B5'] = CIRCLES ws['B4'] = "Red puck" wb.save("sample.xlsx") And the

I want to use double for loop in openpyxl

僤鯓⒐⒋嵵緔 提交于 2019-12-11 16:10:34
问题 I'm making a program that organizes revenues by year and quarter. retyear() list type, Source file data with information of year = [2009, 2017, 2019, ,2020, 2021, 2022, 2099] shtcount=len(retyear) shtcount2=(len(retyear)*5) ---------------------------------problem code-------------------------------------- wb2 = openpyxl.load_workbook("/Users/GiraffeMan/Desktop/02.xlsx", data_only=True) file = "/Users/GiraffeMan/Desktop/02.xlsx" ws2 = wb2['Summary'] for t in range(3, shtcount2, 5): for p in