Questions tagged [xlwings]

Xlwings is a module to allow Excel to be automated with Python instead of VBA.

Xlwings. Replace your VBA code with Python, a powerful yet easy-to-use programming language that is highly suited for numerical analysis. Supports Windows and Mac

1071 questions
7
votes
2 answers

How to click "Enable Macros" when opening Excel using xlwings?

I have a python script on macOS that opens a .xlsm file and executes a macro, but when I reference my macro on line 1, it opens Excel and prompts me to click "Enable Macros". At the moment, I have a sleep function so I can click "Enable Macros"…
Pat Chong
  • 71
  • 4
7
votes
2 answers

How to fit width columns with xlwings

I wrote a function to save data in a WorkBook with xlwings and I want to fit the width column class VehicleClass: def __init__(self, VehClass): # Vehicles 4 - Vehicle Classes self.VehClass = [VehClass] self.VehName = [] …
rvcristiand
  • 442
  • 7
  • 19
7
votes
1 answer

How to import xlwings functions in Excel?

I installed the xlwings Python package using pip and subsequently installed the Excel add-in, using the steps documented here. When I try to open an .xlsm file and then import the Python functions from an identically titled .py file, I get the…
user3725021
  • 566
  • 3
  • 14
  • 32
6
votes
1 answer

xlwings: Save and Close

I am trying to find out how to save and close to an existing workbook using xlwings after writing in it: import xlwings as xw list_of_values = [1, 2, 3] workbook_path = 'abc.xlsx' wb = xw.Book(workbook_path) ws =…
yl_low
  • 1,209
  • 2
  • 17
  • 26
6
votes
2 answers

call python function from excel

I have written a python code, which takes 3 inputs, and return one output val. I try to write an excel function, which passes the three inputs to the python function and returns the output. I have looked into XLwings, but there is so many issues…
CutePoison
  • 4,679
  • 5
  • 28
  • 63
6
votes
4 answers

Replicating YEARFRAC() function from Excel in Python

So I am using python in order to automate some repetitive tasks I must do in excel. One of the calculations I need to do requires the use of yearfrac(). Has this been replicated in python? I found this but it is incorrect for the value I…
user7758051
  • 304
  • 2
  • 5
  • 18
6
votes
2 answers

How to solve import error for pandas using iPython Notebook on Windows?

I'm trying to import pandas while using iPython. My overall purpose is to use XLwings. I'm on Windows 7 and have used Anaconda to install Python, pandas and all the dependencies. Here is my code: from pandas import DataFrame Which…
Greg Carter
  • 323
  • 3
  • 11
5
votes
1 answer

Can a Python script using xlwings be deployed on a server?

We currently have a python script launched locally that periodically generates dozens of Excel files using Xlwings. How can it be deployed on a cloud server as an ETL that would be linked to a job scheduler, so that no human action is needed…
5
votes
1 answer

How to stop python auto date parsing while reading a excel file

i need to read a excel file without changing any date , time format , float format and convert to data-frame. This is working fine if i convert the excel to CSV and read it using read_csv() . eg: import pandas as pd import numpy as np #code for…
prabhaahar
  • 93
  • 1
  • 6
5
votes
1 answer

Columns with 'None' header when importing from xlsx to pandas

Importing a heavily formatted excel worksheet into pandas results in some columns which are entirely blank and have 'None' when viewing df.columns. I need to remove these columns but I'm getting some strange output that makes it hard for me to…
KevOMalley743
  • 551
  • 3
  • 20
5
votes
3 answers

Python xlwings copy-paste formula with relative cell references

I have a formula in cell A1 that is "=C1+$D$1". I would like to use xlwings to copy paste this formula into A3 (keeping the relative cell reference). I would expect the pasted formula in cell A3 to be "=C3+$D$1" instead of "=C1+$D$1". Is there was a…
5
votes
3 answers

How to improve the speed of xlwings UDFs in Excel?

In Python 3, I'm using UDFs in Excel via xlwings to compute a formula. The formula is computed over 4000 times and it takes about 25 seconds to refresh the worksheet. The formula below is used as an example. The formula is called in Excel in each…
J. Daay
  • 93
  • 1
  • 6
5
votes
2 answers

xlwings writing to range on specific sheet

I have been trying to write some lists to a certain sheet on a workbook but am having no luck. My code is: import xlwings as xw from xlwings import Range from xlwings import Book wkb = xw.Book('Master_v3.xlsm') sht =…
naiminp
  • 161
  • 2
  • 3
  • 13
5
votes
1 answer

How to delete columns in xlwings?

I'm using xlwings on Windows (Excel 2007 with Python 2.7) and would like to delete either ranges or columns with xlwings. As far as I could see, deletion of a range or a column is a missing feature, so I tried to follow the instructions given here…
MattiH
  • 53
  • 1
  • 5
5
votes
3 answers

Refresh Pivot Table with XLWINGS

I am trying to refresh a pivot table in excel upon data written by XLWINGS. As I don't know how to do it directly from XLWINGS, I tried to use VBA. Let's split my process in 2 steps: Step1 I launch the python code from vba (my module name is…
ripperlover
  • 61
  • 1
  • 5
1
2
3
71 72