Tag: vb.net

Adding image to Excel

I’m trying to insert an image from file to Excel using EPPlus and vb.net, I added the image to Excel successfully but can’t position it properly. Using img As System.Drawing.Image = Image.FromFile(path) ws.Drawings.AddPicture(“picture1”, img) ws.Drawings.Item(“picture1”).SetPosition(row, 0, column, 0) End Using That’s how I add the image, you can see the results in the image below. […]

VB.NET load Excel document into SQL Server database table via code

I want to load an Excel document into my VB.NET project and then load all the data from the Excel document into my SQL Server database. The table name in SQL Server TCustomers and it has the following columns: CustomerID, FirstName, LastName, OrderID This is how my data looks in the datagridview: CustomerID FirstName LastName […]

VB2010 export SQL dataset to Excel

As a very newbie to any form of coding following a long break, I have started a little project at work for which i’d appreciate a bit of help. I bit of background – When items are submitted to our office they’re input into a bespoke software which stores them in a MS SQL 2012 […]

Importing and Exporting Data into excel via clipboard

I want to import and export 1000+ cell data into and from excel via clipboard. Also the cell data is not in a symmetric grid and the solution needs this flexibility. How do I do this? From my research so far, the cell data should be in the form of tab delimited. use the StringBuilder […]

VB.net find max value in excel range

New to VB coding, so please bear with me. A Windows forms project I’m working on (for both personal interest and as a challenge) is to automate a process at work whereby a job coming into the office will have several items attached to it requiring attention. These items are booked into a SQL DB […]

Copying Excel data and transposing to another worksheet in VB.NET

””””Public Variables Module”””’ Public oXL As Microsoft.Office.Interop.Excel.Application Public oWB As Microsoft.Office.Interop.Excel.Workbook Public oSheet As Microsoft.Office.Interop.Excel.Worksheet ””””End Public Variables Module”””” ””””’Form1.vb”””””’ oXL = New Excel.Application oXL.Visible = True oWB = oXL.Workbooks.Add oSheet = oWB.ActiveSheet oWB.Worksheets(1).range(“a1”).select() oWB.Worksheets(1).Paste() oSheet.UsedRange.Copy() oWB.Worksheets.Add() oWB.Worksheets(“Sheet2”).range(“a1”).select() oWB.Worksheets(“Sheet2″).PasteSpecial(Transpose:=True) ””””’End Form1.vb”””””’ It’s crashing on the pastespecial line with error: Additional information: Exception from HRESULT: 0x800A03EC […]

VB.NET Excel file not connecting with virtual datagridview

I am trying to write a module in my VB.NET application, but it isn’t working properly. I am trying to create a datagridview, and load an excel file into it. However, the Excel isn’t loading in it. Code below Imports Microsoft.Office Imports Microsoft.Office.Interop Imports System.Data.OleDb Imports System.Net.Mail Module m_IslsHpPtSplit Dim UploadFilePath As String Dim UploadFileName […]

vb.net & office: Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass'

I’m developing a vb.net application and it should open and handle a excel file. The problem is that in my pc (and the same could happen in other pc where it could be installed) I have Visio version 2013 and Office (excel, word, etc..) version 2010. Integrating excel in vb is so simple because more […]

Finding rows that contain the same values as each other between two columns

Each row in my workbook is a building ID. Each column in my workbook is an item ID. The cell at the intersection of each item and each building contains a number. This number indicates the quantity of that item in that building. If the building does not have the item, a zero is placed […]

Getting F1 on Datagridview header when Importing from Excel (VB.Net)

I have in my project 2 buttons to import from Excel and export to Excel and a datagridview. I can import Excel files with no problem but when I export from datagridview to Excel and try to re-import that file I only get just one column header with “F1” in it: This is the code […]

MS Excel Spreadsheet is the best Office Software, Excel VBA and Excel Formulas make Spreadsheet work faster.