Przykłady

Arkusz kalkulacyjny z listą użytkowników jPALIO (kod źródłowy do umieszczenia na stronie binarnej)

$xls.setWorkbook()

$xls.createStyle("header", {
  $xls.setAlign("ALIGN_CENTER")
  $xls.setWrapText(true)
  $xls.setFont("Arial", 14, "#000000", true, false, false)
})

$xls.createStyle("table_column_header", {
  $xls.setAlign("ALIGN_CENTER")
  $xls.setBorderLeft("BORDER_THIN")
  $xls.setBorderTop("BORDER_THIN")
  $xls.setBorderRight("BORDER_THIN")
  $xls.setBorderBottom("BORDER_THIN")
  $xls.setWrapText(true)
  $xls.setFont("Arial", 12, "#000000", true, false, false)
})

$xls.createStyle("table_row_header", {
  $xls.setAlign("ALIGN_RIGHT")
  $xls.setBorderLeft("BORDER_THIN")
  $xls.setBorderTop("BORDER_THIN")
  $xls.setBorderRight("BORDER_THIN")
  $xls.setBorderBottom("BORDER_THIN")
  $xls.setWrapText(true)
  $xls.setFont("Arial", 12, "#000000", true, false, false)
})

$xls.createStyle("table_cell", {
  $xls.setAlign("ALIGN_LEFT")
  $xls.setBorderLeft("BORDER_THIN")
  $xls.setBorderTop("BORDER_THIN")
  $xls.setBorderRight("BORDER_THIN")
  $xls.setBorderBottom("BORDER_THIN")
  $xls.setWrapText(true)
  $xls.setFont("Arial", 12, "#000000", false, false, false)
})

$xls.setColumnWidth(0, 0, 1500)
$xls.setColumnWidth(0, 1, 15000)

$=(@row, 0)

$xls.mergeCells(0, $@row, 0, $@row, 1)
$xls.setCellValue(0, $@row, 0, "Users list", "header")
$++(@row)

$xls.setCellValue(0, $@row, 0, "No", "table_column_header")
$xls.setCellValue(0, $@row, 1, "User login", "table_column_header")
$++(@row)

$=(@offset, $-($@row, 1))
$=(@user, (Object[])null)
$for(@user, $sql.read("select id, login from p_users where status = 'N' order by 1", (Object[])null, [Long, String]), {
  $xls.setCellValue(0, $@row, 0, $-($@row, $@offset), "table_row_header")
  $xls.setCellValue(0, $@row, 1, $@user[1], "table_cell")
  $++(row)
})

$writeBinary($xls.getWorkbookBytes())

 

Odczyt dokumentu XLS z dysku i wypisanie jego zawartości na ekran

$xls.setWorkbook($disk.read("/home/data.xls"))

$=(@row, (Object[])null)
$xls.forEachRow(@row, 0, {
  $@row[]<br>
})