Tag: vb.net

从Excel到vb.net图片框的图像

我发现了许多相反的vb.net excel的问题,但没有获得从excel cell(row,column)到图片框的图片。 我的应用程序是一个从Excel文件中获取文本string的模板。 哪些工作正常,但现在我正在尝试传输图片。 我试过picSpindle.Image = shXL.Cells(19, 2).Value但是什么也没做。 不错,但! 将复制和粘贴工作? 码: Imports System Imports System.IO Imports System.Text Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Dim appXL As Excel.Application Dim wbXl As Excel.Workbook Dim shXL As Excel.Worksheet Dim raXL As Excel.Range Dim PartID As String Dim RefCard As String Private Sub Form1_Activated(sender As System.Object, e […]

Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute未定义

使用我在这里find的脚本问题是2012年,我正在使用2008年。 我已经处理了所有的个人资料(连接,variables,URLS等)但是当我尝试运行这个脚本时,我总是收到一个错误。 Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute未定义 使用VB。 Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Imports System.ComponentModel Imports System.Diagnostics <Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _ <System.CLSCompliantAttribute(False)> _ Partial Public Class ScriptMain Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase Enum ScriptResults Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure End Enum Protected Sub SaveFile(ByVal url As String, ByVal localpath As String) Dim loRequest As System.Net.HttpWebRequest Dim loResponse As System.Net.HttpWebResponse Dim […]

在Excel VBA中插入variablesdouble时出错

我有一个程序,插入一个Excel文件的一些价值。 在excel文件中插入一个variables(Double)的值。 单元格的数字格式是“##,## 0.00”。当variables的值是3.0或10.0,但是如果我把3.5或10.3的excel抛出这样的错误: 在第一个单元格中有正确的编号,但是在第二个单元格中出现错误(编号存储为文本)。 代码是这样的: Dim price As Double Dim price2 As Double price = 5.0 price2 = 6.5 oSheet.Range("E1").Value = price oSheet.Range("E2").Value = price2 oSheet.Range("E1").NumberFormat = "€#,##0.00" oSheet.Range("E2").NumberFormat = "€#,##0.00"

如何从自定义function区中的button运行macros?

我使用自定义用户界面编辑器为Microsoft Office创build了自定义function区 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab idMso="TabHome" > <group id="customGroup1" label="My Group" insertAfterMso="GroupEditingExcel"> <button id="customButton1" label="Click Me" size="large" onAction="test()" imageMso="HappyFace" /> </group> </tab> </tabs> </ribbon> </customUI> 我将excel 2007文件保存为Excel Macro-Enabled工作簿 这是我的macros。 它手动运行时工作正常 Sub test() For i = 1 To 10 For j = 1 To i Cells(i, j) = j Next Next End Sub 但是当我按自定义function区中的笑脸button时,会显示以下错误消息。 […]

Excel到VB:无法读取零后面

我正在做一个与Excel的连接,我有一个问题,当我尝试使用一个ID有0后面… 我正在使用一个ListBox并从Excel的工作表中添加ID作为项目。 ID有9个数字,如“123456789”或“098765430”。 因此,我删除了最后4个字符来search具有相同5个数字的ID并添加到另一个ListBox 。 它工作正常,除了与0(零)后面的代码。 Dim ConnectionString As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Application.StartupPath & "\Tabela_Precos.xlsx; Extended Properties=Excel 12.0;") ConnectionString.Open() Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) Dim da For i = 0 To Form1.ListBox1.Items.Count – 1 Dim str As String = Compras.ListBox1.Items(i).ToString Dim prod As String = str.Remove(str.Length – […]

如何使用Microsoft.Office.Interop在Visual Studio中引用Excel NamedRange

我正在使用ExcelDNA从VBA转换到VB.NET的Excel加载项。 在我的代码中,我试图通过它的名字来引用一个NamedRange(就像我可以在VBA中)来设置该名称的'ReferTo'属性。 但是,我得到一个错误,它不能转换我提供给一个整数的名称。 错误:从string“MyNamedRangeName”到types“整数”的转换无效。 在下面的代码中,您可以看到错误发生的位置以及原因。 Imports Microsoft.Office.Interop Imports ExcelDna.Integration Public Class Class1 Sub SetReferToProperty() Dim ap As Excel.Application = ExcelDnaUtil.Application Dim wb as Excel.Workbook = ap.ActiveWorkbook 'This is where the error occurs. Apparently, I can't (?) refer to 'the NamedRange by it's name. I need to use it's index. wb.Names("MyNamedRangeName").RefersTo = 0 'If I use […]

HTML到Excel更改代码

在asp.net(vb)中,我试图编写HTML输出,我可以让用户在Excel中打开一个报告。 这是写我的文件好,但是当Excel打开文件它正在改变HTML代码。 它真正改变的部分是公式! 例如,我正在写出以下内容(文件的一部分): <table> <tr> <td>Trial</td><td x:num x:fmla="=SUM(A2:A10)">0</td> </tr> </tr></table> 如果我在Excel中打开文件,单元格的公式为SUM(A13:A21)。 有什么我可以做,以防止Excel打开时改变这一点? 我希望它有我写的东西,但它正在改变很多! 感谢您的任何想法。

VB.NET中的Excel DNA错误“Xcopy退出代码3”

我得到一个错误,但不能find什么是造成它的任何信息。 Error 6 The command "xcopy C:\Dev\MyProject\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "C:\Dev\PlatinumXL3\PlatinumXL3\bin\x86\Debug\PlatinumXL3-AddIn.xll*" /C /Y exited with code 3. PlatinumXL3

在VB.NET表单的Excel工作表中实时更新数据

我有一个VB.NET与.NET 4.5的表单。 我有一个EXCEL文件并排打开的窗体。 我想在EXCEL表格中看到来自代码LIVE的更新数据。 但不能看到数据。 下面是代码 Imports Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Me.OpenFileDialog1.ShowDialog() Dim xlApp As Application Dim xlWorkBook As Workbook Dim xlWorkSheet As Worksheet xlApp = New ApplicationClass 'xlApp.ScreenUpdating = False xlWorkBook = xlApp.Workbooks.Open("E:\BACKUP\TRY.xls") xlWorkSheet = xlWorkBook.Worksheets("Sheet1") 'display the cells value B2 MsgBox(xlWorkSheet.Cells(8, […]

有没有一种方法可以检查文件是否已经打开?

我想检查C:\ Data.xlsb是否已经打开。 我从这里有下面的代码如何判断某个Excel文件是否使用VB.NET打开? Public Shared Function OpenUnlockedFile(ByVal path As String) As StreamWriter Dim sw As StreamWriter = nothing Try sw = New StreamWriter(path) Catch ex As IOException When System.Runtime.InteropServices.Marshal.GetLastWin32Error() = 32 REM locked, return nothing End Try Return sw End Function 但是我不知道如何使用上面的代码。 我更喜欢sub而不是function。 最好的祝福。