Tag: vb.net

将Excel电子表格保存为PDF

我正在尝试使用Visual Basic将Excel电子表格保存为PDF文件。 我在网上find了一些示例代码(见下面),但是我打开了一个Visual Basic似乎不能识别的Workbook对象。 build议… ' load Excel file Dim workbook As New Workbook() workbook.LoadFromFile("D:\test.xlsx") ' Set PDF template Dim pdfDocument As New PdfDocument() pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape pdfDocument.PageSettings.Width = 970 pdfDocument.PageSettings.Height = 850 'Convert Excel to PDF using the template above Dim pdfConverter As New PdfConverter(workbook) Dim settings As New PdfConverterSettings() settings.TemplateDocument = pdfDocument pdfDocument […]

Excel单元格格式化和四舍五入VB.NET

我怎样才能使这个价值 167,155.30到167.16 13,839.15到13.84 我的代码: xlWs.Cells(dgvRow.Index + 5, dgvColumn.Index + 4).NumberFormat = "#,###.00"

SQL WHERE BETWEEN不select所有数据

我已经在范围内工作的应用程序中编写了导出(Access to Excel)function。 用户有4个RadioButtons :AF,GM,NR和SZ。 假设用户select了rbtnAF ,它会将所有客户加载到Customer_Code字段以A,B,C,D,E或F开始的网格中。 加载数据的代码如下所示: Dim strFields As String = "[Customer_Addresses].[Cust_Code], [Customers].[Customer_Name], [Customer_Addresses].[Contact_Code], [Customer_Addresses].[Contact_Name], " & _ "[Customer_Addresses].[Contact_Type], [Customer_Addresses].[Add1], [Customer_Addresses].[Add2], [Customer_Addresses].[Add3], [Customer_Addresses].[Add4], " & _ "[Customer_Addresses].[Add5], [Customer_Addresses].[Postcode], [Customer_Addresses].[Country], [Customer_Addresses].[Telephone], [Customer_Addresses].[Fax], " & _ "[Customer_Addresses].[Email], [Customer_Addresses].[Mobile_Phone], [Customers].[Customer_Category], [Customers].[Average_Payment_Terms], " & _ "[Customers].[Notes], [Customers].[salesRep], [Customers].[hoEmail], [Customers].[webpage] FROM Customers " & _ "INNER JOIN Customer_Addresses […]

如何使用VB.net在Excel中select单元格A3?

我想使用VB.netselect单元格A3 .. 我试过这样做: sheet.Range("A3:A3").Select() 但是,这给出了一个例外=select方法的范围类失败! 什么是问题,怎么做? 请帮助..我正在等待答复!

如何从Excel中dynamic地删除行并使用VB.net或C#保存

我正在从Excel读取数据并逐行处理文件。 如果进程成功,那么我需要从Excel中删除该行并将其保存。 如果失败,则继续下一行,依此类推。 最初我使用OLEDB从Excel读取数据,但通过使用这个我不能删除行。 我想我们可以通过使用COM组件来解决这个问题。 我很感激你的帮助来解决这个问题。

打开从sql server下载的Office文件时出错

原来的办公文件没有问题(我试过word和excel),但是当我把file upload到数据库,然后从那里下载到我的电脑,并打开下载的文件,我得到警告消息“excel found内容无法读取“等等,并且与原始文件相比,文件变得更加清晰。 确切的错误信息是; “Excel在filename.xls中发现了不可读的内容。是否要恢复此工作簿的内容?如果您信任此工作簿的源,请单击”是“。 我如何上传文件: 'UPLOAD FILE Dim fi As New FileInfo(FilePath) Dim s As Stream = fi.OpenRead() Dim buffer(fi.Length) As Byte 'I put the buffer in database in varbinary(max) format s.Read(buffer, 0, fi.Length) s.Close() 我如何下载并打开文件: 'DOWNLOAD FILE Dim fi As New FileInfo(FilePath) Dim s As Stream = fi.OpenWrite() Dim buffer As Byte() = […]

试图保存Excel – 从HRESULTexception:0x800A03EC

我正在尝试保存一个Excel电子表格。 当我通过Visual Studio(localhost:18928)运行应用程序时,代码工作正常,但是当我尝试将应用程序发布到本地主机并通过IIS(本地主机)运行时,出现以下错误: 来自HRESULT的exception:0x800A03EC说明:执行当前Web请求期间发生未处理的exception。 请查看堆栈跟踪,了解有关错误的更多信息以及源代码的来源。 Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [COMException (0x800a03ec): Exception from HRESULT: 0x800A03EC] Microsoft.Office.Interop.Excel._Worksheet.SaveAs(String Filename, […]

代码无响应

嗨,我是一个新手在vb(又名了解它今天),我写了一个代码,应该算一个列表(在列中列出)有多less相同的序列号,并张贴每个序列号的次数在另一张纸上。 当我运行我的代码时,没有任何反应。 没有错误,在纸上没有新的东西。 我在我的当前代码中将我的列表限制为1-10,因为当它是1-10000 excel崩溃时。 任何人都可以给我指针什么事情发生? 谢谢! Public Sub count() Dim count As Long Dim i, j, a As Integer Dim skuNames() As Double a = 2 count = 0 ReDim skuNames(1) skuNames(0) = Worksheets("RawBarcodeData").Cells(1, 1).Value 'this checks if an sku matches an existing sku in the array and adds if it does not' For […]

我应该去与vb.net或VBA? 大多数与Excel文件工作

我开始一个新的工作 – 我的第一个 – 作为财务总监。 这个工作对于excel文件来说意味着很多,例如格式化一个文档,这样它就可以被SAP等其他财务程序导入和理解,或者用文档中的数据创build图表。 有可能是许多具体的任务,vb.net / vba可以有用的,所以我真的很擅长。 我的问题是,我应该通过Visual Studio或vba通过Excel做vb.net吗? 我的理解是你可以用excel-files来实现基本相同的事情,但也许vba更快,更容易学习和使用。 Vb.net另一方面有一个更好的IDE通过视觉工作室,学习它会给我一个知识,也可以在其他地方更有用。 它是否正确? 我希望能够从一开始就把它弄明白,而不是在一段时间后再去尝试其中的一种。

请求Excel执行C#代码

是否有可能要求Excel启动一个C#方法? 你将如何在Excel中实现这样的呼叫? (即,而不是在VB编程,我想用C#编程) 我可以想象使用VB-macros在后台启动一个C#应用程序,但也许你知道一个更好的方法? 例如,C#代码将在特定的Excel单元格中单击时执行。