Click here to Skip to main content
15,916,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Janus Grids in my application.The data is being displayed properly and I am able to export that Properly to MS_Excel Sheets.But while using FormatConditions in the grid,I am not able to export those formatconditions to Excel.Below is the code I used in Grids.

Sub fillGridProjectDashBoard(ByVal clientID As Integer, ByVal checkClient As Boolean)
Try
'Refresh clear datarow
dtDashBoard.Rows.Clear()

'For grid GridEXDashBoard
Dim daDays As New SqlDataAdapter
Dim cmd As SqlCommand = Class_tblProjectPlan.getProjectDashBoard(clientID, checkClient)
daDays.SelectCommand = cmd
daDays.Fill(dtDashBoard)
GridEXDashBoard.DataSource = dtDashBoard
GridEXDashBoard.RetrieveStructure()

GridEXDashBoard.RootTable.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.False

GridEXDashBoard.RootTable.Columns("id").Visible = False
GridEXDashBoard.RootTable.Columns("Client").TextAlignment = Janus.Windows.GridEX.TextAlignment.Center
GridEXDashBoard.RootTable.Columns("Client").CellStyle.BackColor = Color.LightGray
GridEXDashBoard.RootTable.Columns("Client").Width = 100
GridEXDashBoard.RootTable.Columns("Project").TextAlignment = Janus.Windows.GridEX.TextAlignment.Center
GridEXDashBoard.RootTable.Columns("Project").CellStyle.BackColor = Color.LightGray
GridEXDashBoard.RootTable.Columns("Project").Width = 180
GridEXDashBoard.RootTable.Columns("Budget").TextAlignment = Janus.Windows.GridEX.TextAlignment.Far
GridEXDashBoard.RootTable.Columns("Budget").FormatString = " £ # " GridEXDashBoard.RootTable.Columns("Cost to Date").TextAlignment = Janus.Windows.GridEX.TextAlignment.Far
GridEXDashBoard.RootTable.Columns("Cost to Date").FormatString = "£ #"
GridEXDashBoard.RootTable.Columns("Remaining").Visible = False
GridEXDashBoard.RootTable.Columns("Remaining Budget").TextAlignment = Janus.Windows.GridEX.TextAlignment.Far
GridEXDashBoard.RootTable.Columns("Remaining Budget").FormatString = "£ #"
GridEXDashBoard.RootTable.Columns("Current Recovery Rate").TextAlignment = Janus.Windows.GridEX.TextAlignment.Center
GridEXDashBoard.RootTable.Columns("Current Recovery Rate").FormatString = "p0"
GridEXDashBoard.RootTable.Columns("Current Recovery Rate").Width = 150
GridEXDashBoard.RootTable.Columns("Current").Visible = False

GridEXDashBoard.RootTable.Columns("Further Projected Spend").TextAlignment = Janus.Windows.GridEX.TextAlignment.Far
' GridEXDashBoard.RootTable.Columns("Further Projected Spend").FormatString = "£ #"
GridEXDashBoard.RootTable.Columns("Further Projected Spend").Width = 150
GridEXDashBoard.RootTable.Columns("Projected Recovery Rate").TextAlignment = Janus.Windows.GridEX.TextAlignment.Center
' GridEXDashBoard.RootTable.Columns("Projected Recovery Rate").FormatString = "p0"
GridEXDashBoard.RootTable.Columns("Projected Recovery Rate").Width = 150
GridEXDashBoard.RootTable.Columns("Projected").Visible = False
GridEXDashBoard.RootTable.Columns("Engagement Manager").TextAlignment = Janus.Windows.GridEX.TextAlignment.Center

GridEXDashBoard.RootTable.Columns("Engagement Manager").Width = 150



'For change in back color if value is less than 100%
Dim rowcol, rowcol2 As New Janus.Windows.GridEX.GridEXFormatStyle
rowcol.BackColor = Color.LightPink
rowcol2.ForeColor = Color.Red

For Each row In Me.GridEXDashBoard.GetRows


If 0 < CInt(row.Cells("Current").Value) And CInt(row.Cells("Current").Value) < 1 Then 'Stroy #4053 bikee
row.Cells("Current Recovery Rate").FormatStyle = rowcol
End If

If 0 < CInt(row.Cells("Projected").Value) And CInt(row.Cells("Projected").Value) < 1 Then
row.Cells("Projected Recovery rate").FormatStyle = rowcol
End If

If CInt(row.Cells("Remaining").Value) < 0 Then
row.Cells("Remaining Budget").FormatStyle = rowcol2
End If
Next

Catch ex As Exception
Dim Err As New Kandy.ClassErrorHandler
Err.HandleError(ex, Me.Name, "fillGridProjectDashBoard")
End Try
End Sub
----------------------------------------------------------
And Code I used to Export this Grid to Excel is ::
-----------------------------------------------------------
Private Sub butExportToSpread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butExportToSpread.Click
Dim sFileName As String
Me.Cursor = Cursors.WaitCursor
Try
sFileName = classExportCSV.GenerateFileNamePath(classExportCSV.FileType.ProjectDashboard) 'Get a new file name for this export
GridEXExporter1.ExportMode = ExportMode.AllRows

GridEXExporter1.ExportMode = Janus.Windows.GridEX.ExportMode.AllRows
GridEXExporter1.IncludeChildTables = False
GridEXExporter1.IncludeCollapsedRows = True
GridEXExporter1.IncludeFormatStyle = True
GridEXExporter1.IncludeHeaders = True
GridEXExporter1.IncludeExcelProcessingInstruction = True
GridEXExporter1.SheetName = "Project DashBoard"
Dim fs As New System.IO.FileStream(sFileName, System.IO.FileMode.Create)
GridEXExporter1.Export(fs)
fs.Close()
Process.Start(sFileName)
Catch ex As Exception
Dim Err As New Kandy.ClassErrorHandler
Err.HandleError(ex, Me.Name, "butExportToSpread_Click")
Finally
Me.Cursor = Cursors.Default
End Try
End Sub
-----------------------------------------------------------------
Am I doing anything Wrong??
And What should I do to Export Those FormatConditions Properly??
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900