Creating a MS Excel table with random numbers
Code: "io_ms_excel2.py". Programming language: Python DMelt Version 1.2. Last modified: 07/08/2015. License: Pro
https://datamelt.org/code/cache/io_ms_excel2_850.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from org.apache.poi.xssf.usermodel import XSSFWorkbook 
from java.io import *
from java.util import Random 

wb = XSSFWorkbook()
sheet = wb.createSheet("random numbers");
r=Random(1)
for i in range(50):
   row=sheet.createRow(i)   # create a new row 
   for j in range(20):
      row.createCell(j).setCellValue(r.nextDouble())    
row=sheet.createRow(50)
row.createCell(0).setCellFormula("SUM(A1:A50)") # formula (sum A+B) 
out=FileOutputStream("table2.xlsx");
wb.write(out)
out.close();

Ads help maintain this website.