Add Placeholder text in Excel from VB.Net

If you want to display placeholder text in excel cell, so that user can know what should be entered and on entering the placeholder text goes and entered value will be shown, then you need to format cell as custom format and give below formula

General;General;[Color15]”dd-MMM-yyyy”

Below is the VB.Net code , if you want to do through coding

Protected Sub btn_Click(sender As Object, e As EventArgs)
Using wb = New XLWorkbook()
Dim ws = wb.AddWorksheet(“Sheet1”)
Dim cell = ws.FirstCell()
cell.Value = 0.0
‘cell.DataType = XLDataType.DateTime
cell.Style.NumberFormat.Format = BuildWatermarkFormat(“dd-MMM-yyyy”) ‘”_ * # ##0.00_ ;_ * -# ##0.00_ ;_ * “”-“”??_ ;_ @_ “
‘cell.Style.NumberFormat.SetNumberFormatId(43)
‘cell.Value = 0
ws.Columns(“A”).AdjustToContents()
wb.SaveAs(“d:\test.xlsx”)
End Using
End Sub

Public Function BuildWatermarkFormat(ByVal watermarkText As String, Optional ByVal positiveFormat As String = “General”, Optional ByVal negativeFormat As String = “General”, Optional ByVal textFormat As String = “General”) As String
BuildWatermarkFormat = positiveFormat & “;” & negativeFormat & “;[Color15]” & Chr(34) & watermarkText & Chr(34) & “;” & textFormat
End Function