Click here to Skip to main content
12,763,299 members (37,975 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
Hi All,
I have a excelsheet having 2 sheet namely( Sheet1 name :dictionary, sheet 2 name :LimitWord), now in LimitWord i have 2 column (level and limit), and value level=1 and limit=0. Now using below code i want to update Limit file but it is not applying the changes and not giving error message also.

Please help me to find the solution.
int wordlimit=5
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + FileName + " ;Persist Security Info=False;Extended Properties=Excel 8.0;";//FMT=Delimited(,)';

                string query = "Update [LimitWord$] set WordLimit=" + wordlimit + " where level= 1";

                objCon = new OleDbConnection(connString);
                cmmd = new OleDbCommand(query, objCon);
                cmmd.CommandType = CommandType.Text;

Any help would be appreciated.

Posted 7-Jan-13 2:59am
Updated 7-Jan-13 3:00am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

for excel manipulation i use EPPlus.dll. its called Excel Package
you can download that file

its is quite simple to use

Im Pasting below a sample code that i took from one of my projects. Might be of help to you. it is unedited code

use this import statement

Imports OfficeOpenXml
Sub ExcelOP(filename As String, countryCode As String, data As System.Data.DataTable)

        Using excelPackage As New ExcelPackage()

            Dim ws As ExcelWorksheet = excelPackage.Workbook.Worksheets.Add(countryCode)

            If data.Columns.Count <= 0 Then
                Label1.Text = "No Records"
                For l As Integer = 1 To data.Columns.Count - 1
                    ws.Cells(1, l).Value = HttpUtility.HtmlDecode(data.Columns(l).ToString)

                Using rng As ExcelRange = ws.Cells(1, 1, 1, data.Columns.Count - 1) 'ws.Cells("A1:K1")
                    rng.Style.Font.Bold = True
                    rng.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid
                    rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(192, 192, 192))
                End Using

                Dim totalRecords As Integer = data.Rows.Count

                For r As Integer = 0 To totalRecords - 1
                    For s As Integer = 1 To data.Columns.Count - 1
                        ws.Cells(r + 2, s).Value = HttpUtility.HtmlDecode(data.Rows(r)(s).ToString)
                excelPackage.SaveAs(New FileInfo(filename))
            End If
        End Using
    End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100