2015-04-27 52 views
-2

您是否有过如何在VB.Net 2013中使用EPPlus的例子?,因为我按照说明书编写了一个应用程序,它不起作用。这是代码:EPPLus in VB .net 2013

Imports System Imports System.IO 
Imports officeopenxml 
Public Class Form1 

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    End Sub 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
     Try 
      Dim NewFile As FileInfo = New FileInfo(My.Application.Info.DirectoryPath & "\control room abril.xlsx") 
      Dim NewTemplate = New FileInfo(My.Application.Info.DirectoryPath & "\control room abril.xlsx") 
      Dim XlPackage = New OfficeOpenXml.ExcelPackage(NewFile) 
      Dim sheetDatos = XlPackage.Workbook.Worksheets("27 abril") 
      Dim archivo As String 
      archivo = sheetDatos.Cells(5, 2).Value 
      MessageBox.Show(archivo) 
     Catch ex As Exception 
      MessageBox.Show(ex.Message) 
     End Try 
    End Sub 
End Class 
+1

请解释它是如何工作不表。你会得到一个编译错误(如果是这样,什么错误在哪一行)?你会得到一个运行时异常(如果是这样,哪条线上有什么异常)? – Blackwood

回答

0

这应该工作,除非该文件的路径是错误的,或者路径是正确的,但没有一个叫27 abril