Tag: .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. […]

Fetch maximum number of columns for a specific set of rows

If I want to fetch the max number of columns for a set of rows in Excel, using Visual Studio, how would this be done? Here is my current attempt which yields the maximum number of columns across the whole sheet instead of the specified rows. here are my attempts at this. All the necessary […]

Creating and Exporting Excel using Microsoft.Office.Interop.Excel.dll refeshing the page

Server has Microsoft Office 2003. Code is as below at aspx Page <asp:UpdatePanel ID=”UpdatePanel2″ runat=”server”> <ContentTemplate> <asp:LinkButton ID=”ExportExcel” runat=”server” OnClick=”ExportTabletoExcel_Click” OnClientClick=”ExportTableJqueryMethod”>ExportExcel</asp:LinkButton> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID=”ExportExcel” /> </Triggers> </asp:UpdatePanel> At Code behind using Excel1= Microsoft.Office.Interop.Excel; … protected void ExportTabletoExcel_Click(object sender, EventArgs e) { Excel1.Application excelApp = new Excel1.Application(); …//Adding Data to Excel excelWorkBook.SaveAs(path, Excel1.XlFileFormat.xlWorkbookNormal); excelWorkBook.Close(); …//to […]

OleDb Excel File doesn't save until close the application

My application writes some data to excel file(2007) via OleDb. I am reading values from SQL Server and write to Excel file. It workings correctly. But excel file doesn’t save until close the application. I’m using using{} block both OleDbConnection and SqlConnection. I don’t think it is a Dispose issue. What could be the problem?

Read Unified Diff & extract to excel

I have extracted the Code difference in Unified format from TFS. Now I want to read this diff text (unified format) and then extract it to an excel in a customized format. So what I need is like a parser which can read the diff text and get me the deleted/added changes, line number etc. […]

Read Excel Sheet Data into DataTable or Dataset

I tried to import from Excel to a dataset and an error message occurred. I’m studying this site http://vb.net-informations.com/excel-2007/vb.net_excel_oledb.htm Imports System.Data Imports System.Data.SqlClient Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim MyConnection As System.Data.OleDb.OleDbConnection Dim DtSet As DataSet Dim MyCommand As System.Data.OleDb.OleDbDataAdapter Dim Loc As String […]

Excel just wont Die – Microsoft.Office.Interop.Excel

I am writing an ASP.Net application that is going to have the ability to export data to an excel document after writing. Writing to the file is fine and works using Microsoft.Office.Interop.Excel however when after writing the file 1 or 100 times there is always one or more lingering process that simply will not go […]

Array formula in EPPLUS

I’m trying to generate an excel file with EPPlus that contains a formula summing elements if a condition is met. If read the documentation correctly, last versions (I’m using EPPlus 4.0.5 installed by Nuget) should support such formulas. Here is a short example var pck = new ExcelPackage (fileinfo); var sheet = pck.Workbook.Worksheets.Add (“My sheet”); […]

Reading non-standard excel file with C#

What do i mean by ‘non-standard’? Take a look at these images: http://imgur.com/a/tFqHQ The first one is the non-standard excel file. I’m pretty sure it’s not an excel file, but the file’s extension is .xls and for some reason Excel can open it, and understand it’s structure. The second image is the same file after […]

EPPlus date format not changing correctly

I am creating EXCEL with EPPlus, and need to change the format of Date as per the format passed (dd/mm/yyyy, mm/dd/yyyy etc.) If (schedulestart > -1) Then sheet.Column(schedulestart).Style.Numberformat.Format = fileDownload.DateFormat If (schedulefinish > -1) Then sheet.Column(schedulefinish).Style.Numberformat.Format = fileDownload.DateFormat If (actualstart > -1) Then sheet.Column(actualstart).Style.Numberformat.Format = fileDownload.DateFormat The issue is: with above code, it changes the […]

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