How do you set a cell to null in the VB.Net version of Aspose Cells?
A spreadsheet I generate is later imported by a program that reads the cells. It is not allowed to have zeroes if the data is meant to be empty, and it is also not allowed to have “” in a text cell.
Therefore I need to be able to set the cell to null, but the VB.Net version of Aspose does not have any method like .ClearContents and it doesn’t allow me to use cell.PutValue(nothing).
What do I do?
Hi,
Please see the following code, the code uses two ways to set null. You can choose one of that.
VB.NET
Dim filePath As String = “F:\Downloads\source.xlsx”
Dim m_workbook As Workbook = New Workbook(filePath)
Dim m_worksheet As Worksheet = m_workbook.Worksheets(0)
Dim b3 As Cell = m_worksheet.Cells(“B3”)
Dim b4 As Cell = m_worksheet.Cells(“B4”)
'Set b3 with nothing
Dim obj = Nothing
b3.PutValue(obj)
'Set b4 with db null
b4.PutValue(System.DBNull.Value)
m_workbook.Save(filePath + “.out.xlsx”)