Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
Excel Exporter Header Line
posted

Is there anyway after I have exported my grid, and before I save it to insert a new row at the top of the worksheet that has a long description of what my grid is about? I am using 8.3 about to upgrade to 9.2, but have still not found a way to do this. The description I have is very long and cannot be used at the worksheet or file name because of the need for special characters.Any help or guidance will be greatly appreciated.

 

        Dim x As Integer = 0
        Dim name As String
        Dim exportFile As String
        Dim workbook As New Infragistics.Excel.Workbook
        Dim title As String = Me.ParentForm.Text.Replace(":", " ").Replace("\", " ").Replace("/", "-").Replace("?", "").Replace("*", "").Replace("[", "").Replace("]", "").Replace(",", " ").Replace(".", " ").Replace("  ", " ")
        exportFile = "C:\Documents and Settings\" & Environment.UserName & "\Local settings\Temp\excel.xls"
        'exportFile = "C:\Documents and Settings\" & Environment.UserName & "\Local settings\Temp\" & Me.ParentForm.Text & ".xls"
        For Each obj As Object In UltraGridsForExcel
            Dim grid As Infragistics.Win.UltraWinGrid.UltraGrid
            grid = TryCast(obj, Infragistics.Win.UltraWinGrid.UltraGrid)
            If grid IsNot Nothing Then
                If grid.Name = "" Then
                    name = x.ToString
                    x = x + 1
                Else
                    name = grid.Name
                End If
                name = Me.AbbreviateTitle(name)
                name = name.Replace(":", " ").Replace("\", " ").Replace("/", "-").Replace("?", "").Replace("*", "").Replace("[", "").Replace("]", "").Replace("  ", " ")
                If name.Length > 31 Then
                    name = name.Substring(0, 31)
                End If
                workbook.Worksheets.Add(name)
                If setPrintOptions Then
                    workbook.WindowOptions.SelectedWorksheet.PrintOptions.MaxPagesHorizontally = 1
                    workbook.WindowOptions.SelectedWorksheet.PrintOptions.MaxPagesVertically = 1
                    workbook.WindowOptions.SelectedWorksheet.PrintOptions.Orientation = Infragistics.Excel.Orientation.Landscape
                    workbook.WindowOptions.SelectedWorksheet.PrintOptions.ScalingType = Infragistics.Excel.ScalingType.FitToPages
                End If
                ExcelExporter.Export(grid, workbook.Worksheets(name))
            End If
        Next
        Try
            workbook.Save(exportFile)
        Catch
            exportFile = "C:\Documents and Settings\" & Environment.UserName & "\Local settings\Temp\" & Now.Ticks.ToString & ".xls"
            workbook.Save(exportFile)
        End Try
        Return exportFile