Como dar formato numerico a 2 decimales a celda exel desde formulario VB.NET

gilberto 0 Reputation points
2023-08-24T04:19:07.3766667+00:00

Estoy creando un formulario para crear una hoja de Exel, en VB.Net. Todo va bien, pero quiero formatear la celda en numerica tipo moneda con 2 decimales.

Cual seria la funsion

Gracias

Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2023-08-24T06:59:26.75+00:00

    Hi @gilberto ,

    Suppose you are using the Microsoft.Office.Interop.Excel library to operate Excel.

    You can refer to the following code to set the NumberFormat.

            Dim cell As Range = excelWorksheet.Range("A1")
            cell.Value = 1234.5678
            cell.NumberFormat = "$#,##0.00"
    

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.