CheckBox celltype appears as false when exported to excel

Posted by: eager2knw on 8 September 2017, 1:34 pm EST

  • Posted 8 September 2017, 1:34 pm EST

    hi,


    I have set the value of the checkbox to 0 , in the spread.


    Now when I export to excel , it shows false.


    Doesnt show the checkbox.


    Please Help.


    Thanks,


    Eager2knw

  • Replied 8 September 2017, 1:34 pm EST

    You can use the ImageCellType if you are using the latest version.  I can't quantify how huge the overload might be.  It depends on the size of the image and the number you have.  I imagine it will be a large xls file.
  • Replied 8 September 2017, 1:34 pm EST

    Thanks for the swift reply.  It wud more useful if you can share a sample code for the same.Smile


    To Check for checkboxcelltype across the spread and convert it to imagecelltype.


     and jus before changing it to imagecelltype I have to check the value for the checkbox celltype (if value =0 ; set image1) else (set image2)


    Note: All this manipulation sholud be done within the scope of the SaveExcel method.


     


    Thanks,


    Eager2knw


     

  • Replied 8 September 2017, 1:34 pm EST

    Graphical celltypes are not exported.  Only the value in the cell.
  • Replied 8 September 2017, 1:34 pm EST

    Hi ,


    But its my desparate requirement to show a checkbox in the exported spread. So, I jus thought Instead of using a exporting checkbox celltype, if I can convert all checkbox celltypes in the spread to image celltypes [ i.e : Set a checked checkbox image (if value is true)  or an unchecked checkbox image (if the value is false) and then finally export it to excel. Can u please share a sample C# code for the above requirement.


    My another serious query is, if I search the entire spread for checkbox celltype and then convert those image celltypes, will that be huge overload during export


    Thanks,


    Eager2knw

  • Replied 8 September 2017, 1:34 pm EST

    You will have to write your own sub or function to do this.  It can't be done within the scope of the SaveExcel method.
  • Replied 8 September 2017, 1:34 pm EST

    Here is a routine I wrote to do this...

    Public Sub SaveExcelCheck()
    Dim img As New FarPoint.Win.Spread.CellType.ImageCellType
    Dim imagedown As System.Drawing.Image = System.Drawing.Image.FromFile("c:\forums15\chkdwn.bmp")
    Dim streamdown As New System.IO.MemoryStream
    Dim imageup As System.Drawing.Image = System.Drawing.Image.FromFile("c:\forums15\chkup.bmp")
    Dim streamup As New System.IO.MemoryStream
    imagedown.Save(streamdown, System.Drawing.Imaging.ImageFormat.Bmp)
    imageup.Save(streamup, System.Drawing.Imaging.ImageFormat.Bmp)
    Dim c As FarPoint.Win.Spread.CellType.ICellType
    Dim row, col As Integer
    For row = 0 To FpSpread1.ActiveSheet.RowCount - 1
    For col = 0 To FpSpread1.ActiveSheet.ColumnCount - 1
    c = FpSpread1.ActiveSheet.GetCellType(row, col)

    If TypeOf c Is FarPoint.Win.Spread.CellType.CheckBoxCellType Then
    If FpSpread1.ActiveSheet.Cells(row, col).Value = 0 Then
    FpSpread1.ActiveSheet.Cells(row, col).CellType = img
    FpSpread1.ActiveSheet.Cells(row, col).Value = imagedown
    ElseIf FpSpread1.ActiveSheet.Cells(row, col).Value = 1 Then
    FpSpread1.ActiveSheet.Cells(row, col).CellType = img
    FpSpread1.ActiveSheet.Cells(row, col).Value = imageup
    End If
    End If
    Next
    Next
    FpSpread1.SaveExcel("c:\forums15\check.xls", FarPoint.Excel.ExcelSaveFlags.SaveAsViewed)
    End Sub

  • Replied 8 September 2017, 1:34 pm EST

    Thanks a ton!


    It workedSmile

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels