@@ -0,0 +1,3283 @@
+package com.dua3.meja.samples;%0A%0Aimport com.dua3.meja.model.Row;%0Aimport com.dua3.meja.model.Sheet;%0Aimport com.dua3.meja.model.Workbook;%0Aimport com.dua3.meja.model.generic.GenericWorkbookFactory;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.time.DayOfWeek;%0Aimport java.time.LocalDate;%0Aimport java.time.Month;%0Aimport java.time.format.TextStyle;%0Aimport java.time.temporal.WeekFields;%0Aimport java.util.Locale;%0A%0Apublic class CreateCalendar %7B%0A    %0A    public static void main(String%5B%5D args) throws IOException %7B%0A        try %7B%0A            Path file = Paths.get(%22calendar.xlsx%22);%0A            //LangUtil.check(!Files.exists(file), %22outputfile exists: %22 + file);%0A%0A            writeCalendar(file);%0A        %7D catch (Throwable t) %7B%0A            System.out.println(%22Exception: %22+t.getMessage());%0A            t.printStackTrace(System.err);%0A        %7D%0A    %7D%0A%0A    private static void writeCalendar(Path file) throws IOException %7B%0A        // the locale to create a calendar for%0A        Locale locale = Locale.getDefault();%0A        // week fields for locale%0A        WeekFields weekFields = WeekFields.of(locale);%0A        // get the current year%0A        int year = LocalDate.now().getYear();%0A        // get the first day of week (generally monday or sunday)%0A        DayOfWeek firstDayOfWeek = weekFields.getFirstDayOfWeek();%0A        // Days per week (should be 7)%0A        int daysPerWeek = DayOfWeek.values().length;%0A%0A        Workbook wb = GenericWorkbookFactory.instance().create();%0A%0A        Sheet sheet = wb.createSheet(String.format(%22%25d calendar%22, year));%0A%0A        int monthCols = 8;%0A        int monthRows = 7;%0A        for (Month month: Month.values()) %7B%0A            int r = month.ordinal()/2;%0A            int c = month.ordinal()%252;%0A            %0A            int i = r*(monthCols+2);%0A            int j = c*(monthRows+2);%0A            %0A            // write month name%0A            sheet.getCell(i++,j).set(month.getDisplayName(TextStyle.FULL, locale)).merge(monthCols,1);%0A            %0A            // write weekday names%0A            Row row = sheet.getRow(i++);%0A            for (int d = 0; d %3C 7; d++) %7B%0A                // only use the first two chars of the day name%0A                String dayName=DayOfWeek.values()%5B(d+firstDayOfWeek.ordinal()) %25 daysPerWeek%5D%0A                        .getDisplayName(TextStyle.FULL, locale)%0A                        .substring(0,2);%0A                row.getCell(j+d+1).set(dayName);%0A            %7D%0A            %0A            LocalDate firstOfMonth = LocalDate.of(year, month.getValue(), 1);%0A            int offset = (firstOfMonth.getDayOfWeek().getValue()-firstDayOfWeek.getValue()) %25 daysPerWeek;%0A            for (LocalDate d=firstOfMonth; d.getMonth()==month; d=d.plusDays(1)) %7B%0A                // write date%0A                int idx = offset+d.getDayOfMonth()-1;%0A                int ii = idx/daysPerWeek;%0A                int jj = idx%25daysPerWeek;%0A                sheet.getCell(i+ii,j+jj+1).set(d.getDayOfMonth());%0A                %0A                // write week number%0A                if (d.getDayOfMonth()==1 %7C%7C d.getDayOfWeek()==firstDayOfWeek) %7B%0A                    sheet.getCell(i+ii, j).set(d.get(weekFields.weekOfWeekBasedYear()));%0A                %7D%0A            %7D%0A            %0A        %7D%0A%0A        wb.write(file);%0A    %7D%0A%7D%0A

add calendar sample