Since i made a qoutation system for my boss i'm working with excel 'nd stuff, and it is going pretty well.
I'm able to add products to a datagridview and export this dgv to excel.
In this picture you see my excel file which has the exported products in it
As you can see, in cell C17, the text is based on the ALT+Enter function.
The code which exports the products is the following:
Some explaination with the codes:
I wanted to make a qoutation which has 5 categories with it. "Riolering" is one of the categories. Thats why i used the if-loop.
Little translation to understand:
artikelnaam = productname
hoeveelheid = quantity
eenheid = unit
prijs = price
in this script i translated a little of the dutch words, to make it easier to understand.
Code:
For cnt = 0 To (artikelengrid.Rows.Count - 1)
Dim productname As String = artikelengrid.Rows(cnt).Cells(0).Value.ToString()
Dim category As String = artikelengrid.Rows(cnt).Cells(1).Value.ToString()
Dim ehd As String = artikelengrid.Rows(cnt).Cells(2).Value.ToString()
Dim qty As String = artikelengrid.Rows(cnt).Cells(3).Value.ToString()
.....
ElseIf category = "Riolering" Or categorie = "riolering" Then
xlWorkSheetProducten.Range("A20").Value = "Riolering"
xlWorkSheetProducten.Range("A21").WrapText = True
xlWorkSheetProducten.Range("A21").Rows.AutoFit()
xlWorkSheetProducten.Range("A21").Value += "* " + artikelnaam + vbLf
xlWorkSheetProducten.Range("B21").Value += hoeveelheid + vbLf
xlWorkSheetProducten.Range("C21").Value += "€" + prijs + "/" + eenheid + vbLf
xlWorkSheetProducten.Range("D21").Value += totaalprijs + vbLf
xlWorkSheetProducten.Range("A20").Font.Underline = XlUnderlineStyle.xlUnderlineStyleSingle
As you can see in the picture, is cell 19 for the total of the products. Sorry for the language, i hope it doesn't bother you guys.
But due the multiline cell 17, it wouldn't let me sum up these prices, how is that possible? And is there a way to fix that?
Or is it in the code, that i did something wrong.
I hope you guys can help me, and if you need more information, i'll give it to you.