-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExcelInterop.py
More file actions
21 lines (15 loc) · 848 Bytes
/
ExcelInterop.py
File metadata and controls
21 lines (15 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import clr
#clr.AddReferenceToFileAndPath('C:\\windows\\assembly\\GAC_MSIL\\Microsoft.Office.Interop.Excel\\15.0.0.0__71e9bce111e9429c\\Microsoft.Office.Interop.Excel.dll')
clr.AddReference('Microsoft.Office.Interop.Excel')
import Microsoft.Office.Interop.Excel as Excel
xlApp = Excel.ApplicationClass()
xlApp.Visible = True
xlDisplayAlerts = False
from System.Runtime.InteropServices import Marshal
excel = Marshal.GetActiveObject("Excel.Application")
wb = xlApp.Workbooks.Add()
ws = wb.ActiveSheet
ws.Cells[1,2].Value2 = 'Ian'
#filename = 'C:\\Users\\ijames\\Desktop\\Metric to Imperial Conversion.xlsx'
#filename = r'C:\Users\ijames\Desktop\Metric to Imperial Conversion.xlsx'
#xlWorkbook = xlApp.Workbooks.Open(filename, 0, True, 5, "", "", True, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", False, False, 0, True, 1, 0)