vb.net create blank xlsx file if it doesn't exist
I need to create a blank .xlsx file if it doesn't exist. Here's my code:
StatVar.SchoolName = FrmMain.ComboBoxSchool.Text & ".xlsx"
StatVar.ExportDirectory = "X:\App Exports\Accounting\Purge\" & "Purge "
StatVar.SchoolPath = StatVar.ExportDirectory & StatVar.SchoolName
'create file if it doesn't exist
If Not File.Exists(StatVar.SchoolPath) Then
File.Create(StatVar.SchoolPath)
End If
This creates the workbook, however, upon opening the, I'm prompted with an
error message: "Cannot open becuase the file format or file extension is
not valid"
Is there any way to create a .xlsx file without using 3rd party projects?
No comments:
Post a Comment