openpyxl

openpyxl please do not assume text as a number when importing

我的梦境 提交于 2019-12-12 08:10:13
问题 There are numerous questions about how to stop Excel from interpreting text as a number, or how to output number formats with openpyxl, but I haven't seen any solutions to this problem: I have an Excel spreadsheet given to me by someone else, so I did not create it. When I open the file with Excel, I have certain values like "5E12" (clone numbers, if anyone cares) that appear to display correctly, but there's a little green arrow next to each one warning me that "This appears to be a number

What causes “UserWarning: Discarded range with reserved name” - openpyxl

老子叫甜甜 提交于 2019-12-12 07:43:36
问题 I have a simple EXCEL-sheet with names of cities in column A and I want to extract them and put them in a list: def getCityfromEXCEL(): wb = load_workbook(filename='test.xlsx', read_only=True) ws = wb['Sheet1'] cityList = [] for i in range(2, ws.get_highest_row()+1): acell = "A"+str(i) cityString = ws[acell].value city = ftfy.fix_text_encoding(cityString) cityList.append(city) getCityfromEXCEL() With a small file that worked perfectly (70 rows). Now I'm processing a big file (8300 rows) and

Overwriting data to an existing workbook using Python

£可爱£侵袭症+ 提交于 2019-12-12 04:08:44
问题 I am new to Python and working on a project that I could use some help on. So I am trying to modify an existing excel workbook in order to compare stock data. Luckily, there was a program online that retrieved all the data I need and I have successful been able to pull the data and write the data into a new excel file. However, the goal is to pull the data and put it into an existing excel file. Furthermore, I need to overwrite the cell values in the existing file. I believe xlwings is able

String/regex search over Excel in Python issue

无人久伴 提交于 2019-12-12 04:07:01
问题 I'm a newb to SO, and relatively new to Python, so i'm sorry if this is a simple fix or an inappropriate question. Firstly, my program generally works, but i'm trying to implement some redundancy/catchalls for to make it robust. The program looks over a directory (and sub-dirs) of excel files, opens them individually, scours for data (on a specific sheet), and dumps it out to a csv. There are loops involved as each search term is effectively for the head of a column, and i want 4 values

text to columns with comma delimiter using python

ⅰ亾dé卋堺 提交于 2019-12-12 03:45:15
问题 how to divide a column in to two columns in an excel using a delimiter ', 'and name the header's using python here is my code import openpyxl w=openpyxl.load_workbook('DDdata.xlsx') active=w.active a=active.columns[1] for cellobj in a: s=cellobj.value fila=s.split(',') print(fila) Input file link outputfile 回答1: This looks to be a duplicate of this post, but here's a solution for you to consider: import pandas as pd df = pd.read_excel('input.xlsx') df['First Name'], df['Last Name'] = df[

How to install openpyxl within IronPython

故事扮演 提交于 2019-12-12 03:12:24
问题 I was trying to install openpyxl using the setup.py which in turn uses setuptools. Unfortunately, setuptools cannot be installed within IronPython and I would like to know what other options exist. 回答1: You can download it directly from: https://bitbucket.org/openpyxl/openpyxl/src/default/ and include it on your python path. 来源: https://stackoverflow.com/questions/9980785/how-to-install-openpyxl-within-ironpython

How to use openpyxl to get the cell content via the DefinedName?

萝らか妹 提交于 2019-12-12 02:44:14
问题 For example, the cell's coordinate is A1, setup a DefinedName name="cat" with coordinate='A1' . Then I want to read the content from cell via DefinedName "cat" . But it seems not supported. Any other methods to help? See here for example picture from openpyxl import load_workbook wb = load_workbook(filename="test.xlsx") ws = wb['Sheet1'] cat = ws['cat'].value 回答1: How I found the answer I don't know the function of excel. So I 'named' the cell A1 as cat and save the file. I extracted the file

Formatting Fonts and Alignment

a 夏天 提交于 2019-12-12 02:38:11
问题 I'm trying to add fonts and alignment to an Excel worksheet using Python 2.7 and OpenPyXL 2.4.5. I'm getting the following error, but I don't understand why. Can anyone explain this to me? From my testing, it's related to me setting the font (incorrectly?), and not the actual save. C:\Scripts\Stack_Overflow>xlsx_font_and_alignment.py Traceback (most recent call last): File "C:\Scripts\Stack_Overflow\xlsx_font_and_alignment.py", line 61, in <modu le> main() File "C:\Scripts\Stack_Overflow\xlsx

How to combine one row's data into a single cell using Openpyxl

我与影子孤独终老i 提交于 2019-12-12 01:46:42
问题 I have to combine 3 cells of a row separated by "-". Input is: A1 A9 AMF A2 B9 BMF A1 A9 AMF (Same as 1st row) A4 D9 DMF Expected Output is: A1-A9-AMF A2-B9-BMF A4-D9-DMF I have used the following, for r1 in row: strcell1 = '-'.join(map(str,row)) # converting to string list cell1 = ''.join(strcell1) # joining the cells list_value = [cell1] ws.append(list_value) #writing on a different sheet of same workbook But I am not getting the expected output, is there something that I am missing? 回答1:

how to save the data entered in the textbox in excel using openpyxl

房东的猫 提交于 2019-12-12 01:25:48
问题 i made a program that will input the invoice number and search the excel file(ref my previous question : How to extract a particular row value on inputting value of a particular row), now i want to save the data fetched by the program into a new excel file using openpyxl, but i dont know what is the solution to this, i am using python 3.7.0. my code is from tkinter import * import openpyxl def update_text(info): book_info.delete(1.0, 'end') book_info.insert('end', info) def find_book(): inv