My current console application project uses office.interop.excel to create and update excel files. This project is being upgraded and is moving to new servers where office will not be installed.
I have seen many questions asking about creating excel files without office installed and saw many answers to use EPPlus, ClosedXml etc. But just curious to see whether an excel file can be created using office developer extensions?
If yes, could anyone provide me an example?
My current application's code is similar to below. I removed most of the code and the below code is not compiled. It was shown just to give an idea.
Imports Excel = Microsoft.Office.Interop.Excel
Public Class MyExcelClass
Private Sub Export()
Dim workbooks As Excel.Workbooks = exc.Workbooks
Dim myArrayList = GetData() 'Records in ArrayList
Dim workbook As Excel.Workbook = workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet)
Dim sheets As Excel.Sheets = workbook.Worksheets
Dim worksheet1 As Excel.Worksheet = CType(sheets.Item(1), Excel.Worksheet)
If worksheet1 Is Nothing Then
WriteLog("ERROR: worksheet1 == null")
worksheet1.Name = "My excel sheet"
''create one sheet
Me.CreateSheet(worksheet1, 1, myArrayList)
''save the spreadsheet!
Dim sFilename As String = "C:/1.xlsx"
exc = Nothing
Catch ex As Exception
Private Sub CreateSheet(ByRef sheet As Excel.Worksheet, ByVal iSheetID As Integer, ByVal myArrayList As ArrayList)
.Range("A1:Z10000").Font.Size = 10
'.... More code with range to set the alignment etc.