In this code snippet, we swapped the order of these two lines of code:
netSeries.setPlotOnSecondAxis(true);
netSeries.setType(ChartType.BAR);
This is due to the limitations of Excel, you can confirm this in the Excel interface operation.
BAR and BAR_STACKED types can only be deployed on different Axes, so it must be deployed to SecondAxis first and then the type can be changed.