抑制状态错误BC30002类型'SpreadsheetGear.Drawing.Image'未定义

时间:2017-09-15 08:47:37

标签: c# asp.net visual-studio-2017 spreadsheetgear

我正在为我的项目使用spreadsheetgear。我已使用spreadsheetgear包添加了NuGet,并且它也显示在我的参考列表中。

  

严重级代码说明项目文件行抑制状态错误   BC30002类型'SpreadsheetGear.Drawing.Image'未定义。 devo.net   F:\ devo.net \ DEVO \ Dashboard.aspx 56 Active

Dim image As SpreadsheetGear.Drawing.Image = New SpreadsheetGear.Drawing.Image(shape)

这是我的代码

<%@ Import Namespace="SpreadSheetGear.Drawing" %>
<a href="Compare.html">Compare.html</a><%@ Page Language="VB" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="cache-control" content="no-cache" />

<title>.NET Spreadsheet Component Calculation Sample Using VB.NET and Microsoft Excel Compatible Spreadsheet Component for Microsoft .NET, ASP.NET, C#, VB.NET, XLS and Microsoft Visual Studio .NET</title>
<meta content=".NET spreadsheet component calculation sample using Visual Basic .NET and SpreadsheetGear, a royalty free Microsoft Excel compatible spreadsheet component for the Microsoft .NET Framework featuring the fastest and most complete calculation engine available. Create, read, modify, calculate and write Microsoft Excel workbooks from your Microsoft .NET, ASP.NET, C#, VB.NET and Microsoft Office solutions. Integrates with Microsoft Visual Studio .NET, including IntelliSense and Dynamic Help." name="description" />
<script language="VB" runat="server">



    Sub Page_Load(sender As Object, e As EventArgs)

        Dim stopWatch As New System.Diagnostics.Stopwatch()


        stopWatch.Start()
        ' Open workbooks
        Dim filenameMaster As String = Server.MapPath("Files/DEVO Engine.xlsx")
        Dim filenameInput As String = Server.MapPath("Files/Versions/DEVO Input1.xlsx")
        Dim filenameOutput As String = Server.MapPath("Files/Versions/DEVO Dashboard2.xlsx")
        Dim workbookMaster As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook(filenameMaster)
        Dim workbookInput As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook(filenameInput)
        Dim workbookOutput As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook(filenameOutput)

        ' Copy Inputs to Master

        Dim wsInput As SpreadsheetGear.IWorksheet

        For Each wsInput In workbookInput.Worksheets
            Dim InstInput As SpreadsheetGear.IRange = wsInput.UsedRange
            Dim NameInput As String = wsInput.Name
            Dim DestMaster As SpreadsheetGear.IRange = workbookMaster.Worksheets(NameInput).UsedRange
            Dim type1 As SpreadsheetGear.PasteType = SpreadsheetGear.PasteType.ValuesAndNumberFormats
            Dim operation1 As SpreadsheetGear.PasteOperation = SpreadsheetGear.PasteOperation.None
            workbookMaster.Worksheets(NameInput).Unprotect("")
            InstInput.Copy(DestMaster, type1, operation1, "False", "False")

        Next

        Dim DataMaster As SpreadsheetGear.IRange = workbookMaster.Worksheets("Data").UsedRange
        Dim DataOutput As SpreadsheetGear.IRange = workbookMaster.Worksheets("Data").UsedRange
        Dim type2 As SpreadsheetGear.PasteType = SpreadsheetGear.PasteType.ValuesAndNumberFormats
        Dim operation2 As SpreadsheetGear.PasteOperation = SpreadsheetGear.PasteOperation.None

        DataMaster.Copy(DataOutput, type2, operation2, "False", "False")


        Dim shape As SpreadsheetGear.Shapes.IShape

        For Each shape In workbookMaster.Worksheets("Data").Shapes

            Dim image As SpreadsheetGear.Drawing.Image = New SpreadsheetGear.Drawing.Image(shape)
            Dim size As System.Drawing.Size = image.GetSize()
            Dim bitmap As System.Drawing.Bitmap = image.GetBitmap()
            Dim Imagename As String = Server.MapPath("Files/Images/" & shape.Name & ".png")

            bitmap.Save(Imagename, System.Drawing.Imaging.ImageFormat.Png)
            'Dim Imageurl As String = "Files/" & shape.Name & ".png"
            'SpreadsheetGear.Drawing.Image.ImageUrl = Imageurl
            bitmap.Dispose()

        Next

        stopWatch.Stop()
        Dim ts As TimeSpan = stopWatch.Elapsed
        Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
        System.Diagnostics.Debug.Print("RunTime " + elapsedTime)


        'Send data from Master to Output file
        'Dim instance As SpreadsheetGear.IRange = workbookMaster.Worksheets("Data").UsedRange
        'Dim destination As SpreadsheetGear.IRange = workbookOutput.Worksheets("Data").UsedRange
        'Dim type As SpreadsheetGear.PasteType = SpreadsheetGear.PasteType.ValuesAndNumberFormats
        'Dim operation As SpreadsheetGear.PasteOperation = SpreadsheetGear.PasteOperation.None
        'workbookOutput.Worksheets("Data").Unprotect("")
        'instance.Copy(destination, type, operation, "False", "False")
        'workbookOutput.Save()
        'Server.Transfer("OutputDashboard.html")


    End Sub 'Page_Load



</script>


</head>
<body>


</body>
</html>

1 个答案:

答案 0 :(得分:0)

您必须使用“SpreadsheetGear for .NET Standard”,因为到目前为止,这是SpreadsheetGear提供的NuGet上唯一的产品。

SpreadsheetGear for .NET Standard 不提供与 SpreadsheetGear for .NET SpreadsheetGear.Drawing.Image类相同的功能,因为.NET Standard 1.3(并且新发布的2.0)缺少SpreadsheetGear.Drawing.Image依赖的System.Drawing库; .NET Standard(或基于.NET标准版)中没有其他图形库可以作为合适的替代品,我们可以在其上构建类似的Image类。

注意:我确实为SpreadsheetGear工作,我们对您在.NET标准产品的这个领域可能的替代方案感兴趣,以便将来发布。请随时通过support@spreadsheetgear.com与我们联系,以打开关于此主题的进一步对话。