Tag: asp.net

Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and

I am trying to merge 12 excel files (each having single excel-sheet) into single consolidated excel file that will have 12 excel-sheets using Microsoft.Office.Interop.Excel liabrary and following error: “Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook. To move or copy the data to […]

Moving code to class causes HttpException error

I have written code that exports data from a webpage to excel using EPPlus that I want to reuse multiple times across my project so I have moved the code to its own class. It works fine when in the code on the page but when I move it to its own class I get […]

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 […]

Is there any way to ask a ReportViewer if the result of the query inside a Report will yield more than 65k rows?

I have my reports in a Reporting Services server, inside my .rdl there is a query that accepts parameters. I pass those parameters with an instance of ReportViewer. I have a method that downloads the result of the report in Excel format without using the ReportViewer directly. The method is the following: private void CreateEXCEL(Dictionary<string, […]

Insert data from Excel to database

I have a excel sheet, what I want is I want to upload the excel sheet record into the database table. But in that Emp_Code is identity Qns is Identity I tried like below, protected void btnUpload_Click(object sender, EventArgs e) { DataTable dtExcel = new DataTable(); dtExcel.Clear(); string StrCount = String.Empty; string connString = “”; […]

The Microsoft.ACE.OLEDB.12.0 is working in ISS but not when i uploaded it on godaddy

My code is working fine on IIS but when I deployed the website and try to load excel file I am getting the above error: Microsoft.ACE.OLEDB.12 provider is not registered on the local machine Asp.net 64 bit OS and 32 bit Office 13 ConStr = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” + path + “;Extended Properties=\”Excel 12.0;HDR=Yes;IMEX=2\””;

ASP.NET Cannot launch Excel's file on server

i’m trying to open launch Excel specifing an existing file to open. This is my code: Protected Sub fileManager_SelectedFileOpened(source As Object, e As FileManagerFileOpenedEventArgs) Try Dim FullName As String = e.File.FullName System.Diagnostics.Process.Start(FullName) dvFileError.Visible = False Catch ex As Exception dvFileError.Visible = True lblFileError.Text = ex.Message End Try End Sub In the e.File.FullName i can found […]

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 […]

Extract Selected Row from GridView to Excel Sheet

I have the following gridview, I want to add column as image icon to extract the selected row to Excel sheet. What is the code behined on image onclick event. <%@ Page Title=”” Language=”C#” MasterPageFile=”~/Site1.Master” AutoEventWireup=”true” CodeBehind=”SuppliersPage.aspx.cs” Inherits=”WebApp_UNICEF.SuppliersPage” %> <asp:Content ID=”Content1″ ContentPlaceHolderID=”ContentPlaceHolder1″ runat=”server”> <asp:GridView ID=”grdMain” runat=”server” CellPadding=”4″ ForeColor=”#333333″ GridLines=”None” AutoGenerateSelectButton=”True” onselectedindexchanged=”grdMain_SelectedIndexChanged” BorderColor=”#1EA4DA” BorderStyle=”Solid” BorderWidth=”1px” CellSpacing=”2″ […]

How to remove time from datetime column in excel sheet?

I have written lines of code as public static void GenrateExcel(DataSet ds, string FileName, string TemplateName) { try { ReplcateColumnSpace(ds); HttpContext.Current.Response.ContentType = “application/vnd.ms-excel”; HttpContext.Current.Response.Charset = “”; XmlDataDocument xdd = new XmlDataDocument(ds); XslTransform xt = new XslTransform(); xt.Load(HttpContext.Current.Server.MapPath(“~/ExcelTemplate/” + TemplateName + “.xsl”)); xt.Transform(xdd, null, HttpContext.Current.Response.OutputStream); HttpContext.Current.Response.AddHeader(“Content-Disposition”, “attachment; filename=” + FileName + “.xls”); // HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } […]

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