Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
inponomarev committed Sep 2, 2018
0 parents commit 71d49a2
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE
@@ -0,0 +1,7 @@
Copyright 2018 Ivan Ponomarev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
An example of usage of [Xylophone](https://github.com/CourseOrchestra/xylophone) library.

The command to run in CLI mode:

xylophone -data testdata.xml -template template.xlsx -descr descriptor.xml -out report.xlsx
45 changes: 45 additions & 0 deletions descriptor.xml
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<element name="report">
<!-- Создаём лист -->
<output worksheet="Отчет" sourcesheet="Лист1"/>
<!-- И за ним слева направо заголовки столбцов -->
<iteration mode="horizontal">
<element name="(before)">
<!-- Выводим пустую ячейку в ЛВУ сводной таблицы -->
<output range="A1"/>
</element>
<element name="column">
<output range="B1"/>
</element>
</iteration>
<!-- Выводим строки: итерация с режимом вывода умолчанию, сверху вниз -->
<iteration mode="vertical">
<element name="item">
<!-- И по строке - слева направо -->
<iteration mode="horizontal">
<element name="(before)">
<!-- Заголовок строки -->
<output range="A2"/>
</element>
<!-- И за ним слева направо строку с данными -->
<element name="year">
<output range="B2"/>
</element>
</iteration>
</element>
</iteration>
<iteration>
<element name="totals">
<iteration mode="horizontal">
<element name="(before)">
<!-- Заголовок строки -->
<output range="A3"/>
</element>
<!-- И за ним слева направо строку с данными -->
<element name="year">
<output range="B3"/>
</element>
</iteration>
</element>
</iteration>
</element>
15 changes: 15 additions & 0 deletions runme.groovy
@@ -0,0 +1,15 @@
@Grab('ru.curs:xylophone:6.1.3')
import ru.curs.xylophone.XML2Spreadsheet

baseDir = '.'
new File(baseDir, 'testdata.xml').withInputStream {
input ->
new File(baseDir, 'report.xlsx').withOutputStream {
output ->
XML2Spreadsheet.process(input,
new File(baseDir, 'descriptor.xml'),
new File(baseDir, 'template.xlsx'),
false, output)
}
}
println 'Done.'
Binary file added template.xlsx
Binary file not shown.
26 changes: 26 additions & 0 deletions testdata.xml
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<report>
<column year="2016"/>
<column year="2017"/>
<column year="2018"/>
<item name="Товар 1">
<year amount="365"/>
<year amount="286"/>
<year amount="207"/>
</item>
<item name="Товар 2">
<year amount="95"/>
<year amount="606"/>
<year amount="840"/>
</item>
<item name="Товар 3">
<year amount="710"/>
<year amount="437"/>
<year amount="100"/>
</item>
<totals>
<year amount="1170"/>
<year amount="1329"/>
<year amount="1147"/>
</totals>
</report>

0 comments on commit 71d49a2

Please sign in to comment.