Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Dim wb As PoiWorkbook
wb.InitializeExisting(File.DirAssets, "template.xlsx", "")
Dim s1 As PoiSheet = wb.GetSheet(0) 'unica sheet
Dim i As Int
For i = 1 To 20 ' bar displayed, but is not so
Dim row As PoiRow = s1.CreateRow(i)
row.CreateCellString(0, "Name" & i)
row.CreateCellNumeric(1, Rnd(100, 1000))
Next
SetNamedRange(wb, "sheet1", "Range_name", "$A$2:$A$" & 20) 'set the range
SetNamedRange(wb, "sheet1", "Range_pieces", "$B$2:$B$" & 20)
wb.Save(File.DirApp, "Chart.xlsx")
wb.Close
fx.ShowExternalDocument(File.GetUri(File.DirApp, "Chart.xlsx"))
End Sub