Showing posts from March, 2013

ASP.Net Download Data in Excel File without using interop.

ASP.Net  Download Data in Excel File  without using interop.
Use following code to download data as excel. First you should bind your data to gridview .

Sub saveExcel()
        ' Change the Header Row back to white color
        GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF")

        ' This loop is used to apply stlye to cells based on particular row
        For Each gvrow As GridViewRow In GridView1.Rows
            gvrow.BackColor = Drawing.Color.White

            If gvrow.Cells(4).Text = "True" Then
                gvrow.BackColor = Drawing.Color.Yellow
                'For k As Integer = 0 To gvrow.Cells.Count - 1
                '    gvrow.Cells(k).Style.Add("background-color", "#EFF3FB")
            End If


        Response.AddHeader("content-disposition", "attachment; filename=GridViewToExcel.xls")


ASP.Net Read microsoft project MPP file using opensource mpxj and net.sf.mpxj wih vb

ASP.Net Read microsoft project MPP file using opensource mpxj or net.sf.mpxj in vb language

Due to limitation of interop , i have used mpxj so that it can be used in clients machine for web based access.. Following code is used to read mpp data and bind this to grid which can be later exported to SAP PS Module..

1. Download mpxj from internet unzip it in root folder of application
2. right click on project add reference
3. browse to unzip folder and add mpx.dll
4. import following classes and add functions mentioned in bottom of this code.

Imports net.sf.mpxj
Imports net.sf.mpxj.reader
Imports System.Collections.Generic
Imports System.Collections
Imports java.util

Partial Class _wbsx
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

 Dim maxlevel = 0
        Dim currentlevel = 0
        Dim wbs = ""

        Dim reader = ProjectReaderUtility.getProjectReader(Server.MapPath("./upload/") & "…

ASP.Net Reading Microsoft Project MPP File using interop.

ASP.Net Reading Microsoft Project MPP File using interop.
Its easy but works only on running at machine having visual studio installed. Below is a program made for importing data from MPP to SAP PS Module. The code can read data from MPP File and bind to a Grid for display.

Imports Microsoft.Office.Interop.MSProject

Page Load

        Dim appclass As New Application

        Dim oMissing = Type.Missing
        Dim bopen = appclass.FileOpenEx(Server.MapPath("./upload/") & "mspfile.mpp", True, PjMergeType.pjDoNotMerge, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, PjPoolOpen.pjDoNotOpenPool, oMissing, oMissing, oMissing, oMissing)

        If bopen = False Then
            lblMsg.Text = "File not opened"
            Exit Sub
        End If

        appclass.Visible = False
        Dim project As Project = appclass.ActiveProject

        Dim temp As String = "
        Dim id As Integer = 1
        '########### ' Store t…

ASP.NET , Mysql and Unicode for Hindi

ASP.NET , Mysql and Unicode for Hindi

Step 1. In mysql table structure change latin1_swedish_ci  to utf8_unicode_ci  

subject text utf8_unicode_ci
sender text latin1_swedish_ci

Step2: Add CharacterSet=utf8; in your connection string

add name="vinConn" connectionString="server=;User Id=admin;password=**;database=entertrack;Persist Security Info=True;Character Set=utf8; " providerName="MySql.Data.MySqlClient"/>
Step3: Use N in insert statement
like insert into tesr (subject) values (N'महानदी ')

Google+ Followers