EPPlus在VB.net

我试图用EPPlus填充现有的xls文件,但我从来没有使用它。 我必须在数据库中search我的数据。

插入数据后,用户可以保存在他的电脑上的文件,我不知道任何关于EPPlus所以,我做了这个:

Dim ExistFile = Server.MapPath("~/Vues/tableau_qualif1.xlsx") Dim File = New FileInfo(ExistFile) Dim Connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Formation_2014ConnectionString").ConnectionString) Dim i = 3 Dim Query = "SELECT * FROM personnes" Using package As New ExcelPackage(File) package.Load(New FileStream(ExistFile, FileMode.Open)) Dim workSheet As ExcelWorksheet = package.Workbook.Worksheets("Feuil1") Try 'Ouverture de la connexion Connection.Open() 'Définition de la commande et de ses paramètres Dim Commande As New SqlCommand(Query, Connection) 'Création du SqlDataAdapter et du DataSet (En fonction de la Commande) Dim Adaptateur As New SqlDataAdapter(Commande) Dim MonDataSet As New DataSet Try 'Définition de l'adaptateur Adaptateur.Fill(MonDataSet, "Personnes") For Each Ligne As DataRow In MonDataSet.Tables("Personnes").Rows() workSheet.Cells("A" & i).Value = Ligne("Prenom_personne").ToString() & " " & Ligne("Nom_personne").ToString() i = i + 1 Next Catch ex As Exception MsgBox(ex.Message) End Try Catch ex As Exception MsgBox(ex.Message) End Try 'Fermeture de la connexion Connection.Close() package.Save() Response.Clear() Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Response.BinaryWrite(package.GetAsByteArray()) Response.End() End Using 

此代码崩溃

 Response.BinaryWrite(package.GetAsByteArray()) 

任何人都可以帮助我呢? 非常感谢 !

我的线

 package.save() 

导致我的问题,我只是删除这条线,一切工作正常!