Example usage for org.apache.poi.hssf.usermodel HSSFCell ENCODING_UTF_16

List of usage examples for org.apache.poi.hssf.usermodel HSSFCell ENCODING_UTF_16

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFCell ENCODING_UTF_16.

Prototype

short ENCODING_UTF_16

To view the source code for org.apache.poi.hssf.usermodel HSSFCell ENCODING_UTF_16.

Click Source Link

Usage

From source file:cn.edu.zju.acm.onlinejudge.action.ShowRankListAction.java

License:Open Source License

private byte[] exportToExcel(AbstractContest contest, List<Problem> problems, RankList ranklist)
        throws Exception {
    List<RankListEntry> entries = ranklist.getEntries();
    long time = this.getTimeEscaped(contest);

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();/*from  w w w. j  a  v a  2 s . c  o  m*/
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue(contest.getTitle());
    if (ranklist.getRole() != null) {
        row = sheet.createRow(1);
        cell = row.createCell((short) 0);
        cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue(ranklist.getRole().getDescription());
    }

    row = sheet.createRow(2);
    cell = row.createCell((short) 0);
    cell.setCellValue("Length");
    cell = row.createCell((short) 1);
    cell.setCellValue(Utility.toTime(contest.getLength() / 1000));

    row = sheet.createRow(3);
    cell = row.createCell((short) 0);
    cell.setCellValue("Time Escaped");
    cell = row.createCell((short) 1);
    cell.setCellValue(Utility.toTime(time / 1000));

    row = sheet.createRow(5);
    row.createCell((short) 0).setCellValue("Rank");
    row.createCell((short) 1).setCellValue("Handle");
    row.createCell((short) 2).setCellValue("Nickname");
    row.createCell((short) 3).setCellValue("Solved");
    short columnIndex = 4;
    for (Problem problem2 : problems) {
        Problem problem = problem2;
        row.createCell(columnIndex).setCellValue(problem.getCode());
        columnIndex++;
    }
    row.createCell(columnIndex).setCellValue("Penalty");

    int rowIndex = 6;
    for (RankListEntry rankListEntry : entries) {
        RankListEntry entry = rankListEntry;
        row = sheet.createRow(rowIndex);
        row.createCell((short) 0).setCellValue(rowIndex - 5);
        row.createCell((short) 1).setCellValue(entry.getUserProfile().getHandle());
        String nick = entry.getUserProfile().getHandle();
        if (entry.getUserProfile().getNickName() != null) {
            nick = entry.getUserProfile().getNickName();
        }
        cell = row.createCell((short) 2);
        cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue(nick);

        row.createCell((short) 3).setCellValue(entry.getSolved());

        for (short i = 0; i < problems.size(); ++i) {
            String score = entry.getAcceptTime(i) > 0
                    ? entry.getAcceptTime(i) + "(" + entry.getSubmitNumber(i) + ")"
                    : "" + entry.getSubmitNumber(i);
            row.createCell((short) (4 + i)).setCellValue(score);
        }
        row.createCell((short) (4 + problems.size())).setCellValue(entry.getPenalty());
        rowIndex++;
    }

    // output to stream
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        wb.write(out);
        return out.toByteArray();
    } finally {
        out.close();
    }
}

From source file:com.aimluck.eip.modules.screens.AddressBookCompanyWordXlsExportScreen.java

License:Open Source License

private void setupAddressBookSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    String sheet_name = "()";
    // ?//from  w w w . j ava2 s  .co  m
    String[] headers = { "??", "??", "??", "?", "?",
            "?", "FAX", "URL" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16 };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    AddressBookCompanyWordSelectData listData = new AddressBookCompanyWordSelectData();

    listData.initField();
    listData.setRowsNum(1000);
    listData.doSelectList(this, rundata, context);
    int page_num = listData.getPagesNum();
    int current_page = 1;
    while (true) {
        int listsize = listData.getList().size();
        AddressBookCompanyResultData rd;
        for (int j = 0; j < listsize; j++) {
            rd = (AddressBookCompanyResultData) listData.getList().get(j);
            String[] rows = { rd.getCompanyName().getValue(), rd.getCompanyNameKana().getValue(),
                    rd.getPostName().getValue(), rd.getZipcode().getValue(), rd.getAddress().getValue(),
                    rd.getTelephone().getValue(), rd.getFaxNumber().getValue(), rd.getUrl().getValue() };

            rowcount = rowcount + 1;
            addRow(sheet.createRow(rowcount), cell_enc_types, rows);
        }

        current_page++;
        if (current_page > page_num) {
            break;
        }
        listData.setCurrentPage(current_page);
        listData.doSelectList(this, rundata, context);
    }

    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid,
            "()",
            163/* ALEventlogConstants.PORTLET_TYPE_ADDRESSBOOK_XLS_SCREEN */);
}

From source file:com.aimluck.eip.modules.screens.AddressBookCompanyXlsExportScreen.java

License:Open Source License

private void setupAddressBookSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    String sheet_name = "()";
    // ?/*from ww w .  j av a  2s  .  c  o m*/
    String[] headers = { "??", "??", "??", "?", "?",
            "?", "FAX", "URL" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16 };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    AddressBookCompanySelectData listData = new AddressBookCompanySelectData();

    listData.initField();
    listData.setRowsNum(1000);
    listData.doSelectList(this, rundata, context);
    int page_num = listData.getPagesNum();
    int current_page = 1;
    while (true) {
        int listsize = listData.getList().size();
        AddressBookCompanyResultData rd;
        for (int j = 0; j < listsize; j++) {
            rd = (AddressBookCompanyResultData) listData.getList().get(j);
            String[] rows = { rd.getCompanyName().getValue(), rd.getCompanyNameKana().getValue(),
                    rd.getPostName().getValue(), rd.getZipcode().getValue(), rd.getAddress().getValue(),
                    rd.getTelephone().getValue(), rd.getFaxNumber().getValue(), rd.getUrl().getValue() };

            rowcount = rowcount + 1;
            addRow(sheet.createRow(rowcount), cell_enc_types, rows);
        }

        current_page++;
        if (current_page > page_num) {
            break;
        }
        listData.setCurrentPage(current_page);
        listData.doSelectList(this, rundata, context);
    }

    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid,
            "()",
            163/* ALEventlogConstants.PORTLET_TYPE_ADDRESSBOOK_XLS_SCREEN */);
}

From source file:com.aimluck.eip.modules.screens.AddressBookWordXlsExportScreen.java

License:Open Source License

private void setupAddressBookSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    String sheet_name = "";
    // ?//from w  ww  .  ja v  a2 s  .c o  m
    String[] headers = { "???", "???", "", "?",
            "??", "?", "??",
            "??", "??", "?", "?", "?", "FAX?",
            "URL", "???", "" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16 };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    AddressBookFilterdSelectData listData;
    listData = new AddressBookFilterdSelectData();

    listData.initField();
    listData.setRowsNum(1000);
    listData.doSelectList(this, rundata, context);
    listData.loadGroups(rundata, context);
    int page_num = listData.getPagesNum();
    int current_page = 1;
    while (true) {
        int listsize = listData.getList().size();
        AddressBookResultData rd;
        for (int j = 0; j < listsize; j++) {
            rd = (AddressBookResultData) listData.getList().get(j);
            String[] rows = { rd.getName().getValue(), rd.getNameKana().getValue(), rd.getEmail().getValue(),
                    rd.getTelephone().getValue(), rd.getCellularPhone().getValue(),
                    rd.getCellularMail().getValue(), rd.getCompanyName().getValue(),
                    rd.getCompanyNameKana().getValue(), rd.getPostName().getValue(), rd.getZipcode().getValue(),
                    rd.getCompanyAddress().getValue(), rd.getCompanyTelephone().getValue(),
                    rd.getCompanyFaxNumber().getValue(), rd.getCompanyUrl().getValue(),
                    rd.getPositionName().getValue(), rd.getNoteRaw() };

            rowcount = rowcount + 1;
            addRow(sheet.createRow(rowcount), cell_enc_types, rows);
        }

        current_page++;
        if (current_page > page_num) {
            break;
        }
        listData.setCurrentPage(current_page);
        listData.doSelectList(this, rundata, context);
    }

    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid, "",
            163/* ALEventlogConstants.PORTLET_TYPE_ADDRESSBOOK_XLS_SCREEN */);
}

From source file:com.aimluck.eip.modules.screens.AddressBookXlsExportScreen.java

License:Open Source License

private void setupAddressBookSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    AddressBookFilterdSelectData listData;
    listData = new AddressBookFilterdSelectData();

    listData.initField();//  ww  w.j  a v a  2s.co  m
    listData.setRowsNum(1000);
    listData.doSelectList(this, rundata, context);

    String sheet_name = "";
    // ?
    String[] headers = { "???", "???", "", "?",
            "??", "?", "??", "???" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16 };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    int listsize = listData.getCount();
    AddressBookResultData rd;
    for (int j = 0; j < listsize; j++) {
        rd = (AddressBookResultData) listData.getList().get(j);
        String[] rows = { rd.getName().getValue(), rd.getNameKana().getValue(), rd.getEmail().getValue(),
                rd.getTelephone().getValue(), rd.getCellularPhone().getValue(), rd.getCellularMail().getValue(),
                rd.getCompanyName().getValue(), rd.getPositionName().getValue() };

        rowcount = rowcount + 1;
        addRow(sheet.createRow(rowcount), cell_enc_types, rows);
    }

    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid, "",
            163/* ALEventlogConstants.PORTLET_TYPE_ADDRESSBOOK_XLS_SCREEN */);
}

From source file:com.aimluck.eip.modules.screens.ALXlsScreen.java

License:Open Source License

/**
 * //from  w  w  w .ja  va  2  s.c  o  m
 * @param wb
 * @param sheet_name
 * @param headers
 *          ?
 * @param cell_enc_types
 *          ?
 * @return
 */
protected HSSFSheet createHSSFSheet(HSSFWorkbook wb, String sheet_name, String[] headers,
        short[] cell_enc_types) {

    HSSFSheet sheet = wb.createSheet(sheet_name);
    wb.setSheetName(0, sheet_name, HSSFWorkbook.ENCODING_UTF_16);

    HSSFRow row1 = sheet.createRow(0);
    int len = headers.length;
    for (int i = 0; i < len; i++) {
        HSSFCell cell_row1 = row1.createCell((short) i);
        cell_row1.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell_row1.setCellValue(headers[i]);
    }

    return sheet;
}

From source file:com.aimluck.eip.modules.screens.ALXlsScreen.java

License:Open Source License

/**
 * xls??//  w  w w  .  ja v  a2s. c om
 * 
 * @param newrow
 * @param cell_enc_types
 * @param rows
 */
protected void addRow(HSSFRow newrow, short[] cell_enc_types, String[] rows) {
    int len = rows.length;
    for (int j = 0; j < len; j++) {
        HSSFCell cell_newrow = newrow.createCell((short) j);
        if (cell_enc_types[j] == HSSFCell.CELL_TYPE_NUMERIC) {
            try {
                cell_newrow.setCellValue(Double.parseDouble(rows[j]));
            } catch (Exception e) {
                cell_newrow.setCellValue("");
            }
        } else if (cell_enc_types[j] == HSSFCell.ENCODING_UTF_16) {
            cell_newrow.setEncoding(cell_enc_types[j]);
            cell_newrow.setCellValue(rows[j]);
        } else {
            cell_newrow.setCellValue(rows[j]);
        }
    }
}

From source file:com.aimluck.eip.modules.screens.ALXlsScreen.java

License:Open Source License

protected void addFooter(HSSFRow newrow, short[] cell_enc_types, String[] rows) {
    int len = rows.length;
    for (int j = 0; j < len; j++) {
        HSSFCell cell_newrow = newrow.createCell((short) j);
        if (cell_enc_types[j] == HSSFCell.CELL_TYPE_NUMERIC) {
            cell_enc_types[j] = HSSFCell.CELL_TYPE_FORMULA;
            cell_newrow.setCellValue(rows[j]);
        } else if (cell_enc_types[j] == HSSFCell.ENCODING_UTF_16) {
            cell_newrow.setEncoding(cell_enc_types[j]);
            cell_newrow.setCellValue(rows[j]);
        } else {//from w w w  .j  a v  a  2s .c  om
            cell_newrow.setCellValue(rows[j]);
        }
    }
}

From source file:com.aimluck.eip.modules.screens.ExtTimecardNewXlsExportScreen.java

License:Open Source License

private void setupTimecardSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    ExtTimecardSelectData listData = new ExtTimecardSelectData();
    listData.initField();//w  w  w  .j  av  a  2s . c o  m
    listData.setRowsNum(1000);
    listData.doViewList(this, rundata, context);

    String sheet_name = "";
    // ?
    String[] headers = { "???", "", "", "", "", "",
            "", "", "", "??",
            "?", "", "", "?",
            "?", "?", "", "?", "",
            "", "", "", "???", "?", "",
            "", "", "", "", "", "", "",
            "", "", "" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16,
            HSSFCell.ENCODING_UTF_16, HSSFCell.ENCODING_UTF_16 };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    String user_name = ALEipUtils.getUserFullName(Integer.parseInt(listData.getTargetUserId()));// ???
    String system_name = ExtTimecardUtils
            .getEipTExtTimecardSystemByUserId(Integer.parseInt(listData.getTargetUserId())).getSystemName();

    ExtTimecardListResultDataContainer container = ExtTimecardUtils.groupByWeek(listData.getQueryStartDate(),
            listData.getAllList(), null);
    container.calculateWeekOvertime();

    ExtTimecardListResultData tclistrd = null;
    List<ExtTimecardListResultData> daykeys = listData.getDateListKeys();
    int daykeysize = daykeys.size();
    for (int i = 0; i < daykeysize; i++) {
        tclistrd = daykeys.get(i);
        tclistrd.setWeekOvertime(container.getWeekOvertime(tclistrd));
        tclistrd.setStatutoryHoliday(container.isStatutoryOffDay(tclistrd));
        tclistrd.calculateWeekOvertime();

        String date = "";// 
        String day = ""; // 
        String service_form = system_name; // 
        String clock_in_time = "";// 
        String clock_out_time = "";// 
        String work_day = "0"; //  0 or 1
        String work_hour = "0";// 
        String overtime_day = "0";// 
        String overtime_hour = "0";// 
        String overtime_within_statutory_working_hour = "0";// 
        String off_day = "0";// 
        String off_hour = "0";// 
        String late_coming_day = "0";// ?
        String early_leaving_day = "0";// 
        String absent_day = "0";// 
        String paid_holiday = "0";// 
        String compensatory_holiday = "0";// 
        String other_day = "0";// ???
        String remark = "";// 
        String reason = "";// ?
        String official_off_day = "0", statutory_off_day = "0";
        String total_work_hour = "0";
        String midnight_work_hour = "0", midnight_overtime_hour = "0";
        String statutory_off_day_regular_work_hour = "0", statutory_off_day_overtime_hour = "0",
                statutory_off_day_midnight_work_hour = "0", statutory_off_day_regular_midnight_work_hour = "0",
                statutory_off_day_within_statutory_overtime_hour = "0";
        String off_day_regular_work_hour = "0", off_day_overtime_hour = "0", off_day_midnight_work_hour = "0",
                off_day_regular_midnight_work_hour = "0", off_day_within_statutory_overtime_hour = "0";
        String total_off_day_work_hour = "0", total_statutory_off_day_work_hour = "0";
        String total_midnight_work_hour = "0";
        String rest_hour = "0";
        String[] out_going = new String[EipTExtTimecard.OUTGOING_COMEBACK_PER_DAY];// 
        String[] come_back = new String[EipTExtTimecard.OUTGOING_COMEBACK_PER_DAY];// 

        if (tclistrd.getRd() == null) {

            // ExtTimecardResultData rd = tclistrd.getRd();

            date = tclistrd.getDateStr("yyyy/MM/dd");
            day = tclistrd.getDateStr("EE");
        } else {

            ExtTimecardResultData rd = tclistrd.getRd();

            // ExtTimecardSummaryResultData srd = tclistrd.get

            date = tclistrd.getDateStr("yyyy/MM/dd");
            day = tclistrd.getDateStr("EE");
            String type = rd.getType().toString();
            if (!rd.getIsNullClockInTime()) {
                clock_in_time = rd.getClockInTime("HH:mm");
                clock_out_time = rd.getClockOutTime("HH:mm");
                if (tclistrd.getWorkHour() != ExtTimecardListResultData.NO_DATA) {
                    work_day = "1";
                    work_hour = Float.toString(tclistrd.getWorkHour());
                } else {
                    work_hour = "0";
                }
                if (tclistrd.getOvertimeHourWithoutRestHour() > 0.0) {
                    overtime_day = "1";
                    overtime_hour = Float.toString(tclistrd.getOvertimeHourWithoutRestHour());
                } else {
                    overtime_hour = "0";
                }
                /**  */
                if (tclistrd.getWithinStatutoryOvertimeWorkHourWithoutOffday() > 0.0) {
                    overtime_within_statutory_working_hour = Float
                            .toString(tclistrd.getWithinStatutoryOvertimeWorkHourWithoutOffday());
                }
                if (tclistrd.getOffHour() > 0.0) {
                    off_day = "1";
                    // ???
                    if (container.isStatutoryOffDay(tclistrd)) {
                        total_statutory_off_day_work_hour = Float.toString(tclistrd.getTotalWorkHour());
                        statutory_off_day = "1";
                        statutory_off_day_regular_work_hour = Float.toString(tclistrd.getInworkHour());
                        statutory_off_day_overtime_hour = Float.toString(tclistrd.getOvertimeHour());
                        statutory_off_day_midnight_work_hour = Float
                                .toString(tclistrd.getMidnightOvertimeWorkHour());
                        statutory_off_day_regular_midnight_work_hour = Float
                                .toString(tclistrd.getMidnightRegularWorkHour());
                        if (tclistrd
                                .getWithinStatutoryOvertimeWorkHour() != ExtTimecardListResultData.NO_DATA) {
                            statutory_off_day_within_statutory_overtime_hour = Float
                                    .toString(tclistrd.getWithinStatutoryOvertimeWorkHour());
                        }
                    } else {
                        total_off_day_work_hour = Float.toString(tclistrd.getTotalWorkHour());
                        official_off_day = "1";
                        off_day_regular_work_hour = Float.toString(tclistrd.getInworkHour());
                        off_day_overtime_hour = Float.toString(tclistrd.getOvertimeHour());
                        off_day_midnight_work_hour = Float.toString(tclistrd.getMidnightOvertimeWorkHour());
                        off_day_regular_midnight_work_hour = Float
                                .toString(tclistrd.getMidnightRegularWorkHour());
                        if (tclistrd
                                .getWithinStatutoryOvertimeWorkHour() != ExtTimecardListResultData.NO_DATA) {
                            off_day_within_statutory_overtime_hour = Float
                                    .toString(tclistrd.getWithinStatutoryOvertimeWorkHour());
                        }
                    }
                    off_hour = Float.toString(tclistrd.getOffHour());
                } else {
                    off_hour = "0";
                    /**  */
                    if (tclistrd.getMidnightRegularWorkHour() != ExtTimecardListResultData.NO_DATA) {
                        midnight_work_hour = Float.toString(tclistrd.getMidnightRegularWorkHour());
                    }
                    if (tclistrd.getMidnightOvertimeWorkHour() != ExtTimecardListResultData.NO_DATA) {
                        midnight_overtime_hour = Float.toString(tclistrd.getMidnightOvertimeWorkHour());
                    }
                }
            }
            if (tclistrd.getMidnightWorkHour() > 0.0) {
                total_midnight_work_hour = Float.toString(tclistrd.getMidnightWorkHour());
            }
            if (tclistrd.getTotalWorkHour() > 0.0) {
                total_work_hour = Float.toString(tclistrd.getTotalWorkHour());
            }
            if (rd.getRefixFlag().getValue() == "1") {
                reason = rd.getReason().getValue();
            }
            if (rd.getRemarksFlg()) {
                remark = rd.getRemarks().getValue();
            }
            if (tclistrd.getRestHour() > 0.0) {
                rest_hour = Float.toString(tclistrd.getRestHour());
            }
            late_coming_day = tclistrd.isLateComing() ? "1" : "0";
            early_leaving_day = tclistrd.isEarlyLeaving() ? "1" : "0";
            absent_day = type.equals(EipTExtTimecard.TYPE_ABSENT) ? "1" : "0";
            paid_holiday = type.equals(EipTExtTimecard.TYPE_HOLIDAY) ? "1" : "0";
            compensatory_holiday = type.equals(EipTExtTimecard.TYPE_COMPENSATORY) ? "1" : "0";
            other_day = type.equals(EipTExtTimecard.TYPE_ETC) ? "1" : "0";

            List<Map<String, String>> list = tclistrd.getOutgoingComeback_xls();
            for (int j = 0; j < EipTExtTimecard.OUTGOING_COMEBACK_PER_DAY; j++) {
                Map<String, String> map = list.get(j);
                out_going[j] = map.get("outgoing");
                come_back[j] = map.get("comeback");
            }
        }

        String[] rows = { user_name, date, day, service_form, clock_in_time, clock_out_time, work_day,
                official_off_day, statutory_off_day, total_work_hour, work_hour,
                overtime_within_statutory_working_hour, overtime_hour, total_off_day_work_hour,
                total_statutory_off_day_work_hour, total_midnight_work_hour, rest_hour, late_coming_day,
                early_leaving_day, absent_day, paid_holiday, compensatory_holiday, other_day, reason, remark,
                out_going[0], come_back[0], out_going[1], come_back[1], out_going[2], come_back[2],
                out_going[3], come_back[3], out_going[4], come_back[4] };
        rowcount = rowcount + 1;
        addRow(sheet.createRow(rowcount), cell_enc_types, rows);
    }
    /*
     * rowcount = rowcount + 1; String NOTHING = null; String work_day =
     * "=SUM(G2:G" + rowcount + ")"; String work_hour = "=SUM(H2:H" + rowcount +
     * ")"; String overtime_day = "=SUM(I2:I" + rowcount + ")"; String
     * overtime_hour = "=SUM(J2:J" + rowcount + ")"; String off_day =
     * "=SUM(K2:K" + rowcount + ")"; String off_hour = "=SUM(L2:L" + rowcount +
     * ")"; String late_coming_day = "=SUM(M2:M" + rowcount + ")"; String
     * early_leaving_day = "=SUM(N2:N" + rowcount + ")"; String absent_day =
     * "=SUM(O2:O" + rowcount + ")"; String paid_holiday = "=SUM(P2:P" +
     * rowcount + ")"; String compensatory_holiday = "=SUM(Q2:Q" + rowcount +
     * ")"; String other_day = "=SUM(R2:R" + rowcount + ")"; String[] rows = {
     * NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, work_day,
     * work_hour, overtime_day, overtime_hour, off_day, off_hour,
     * late_coming_day, early_leaving_day, absent_day, paid_holiday,
     * compensatory_holiday, other_day, };
     * 
     * addFooter(sheet.createRow(rowcount), cell_enc_types, rows);
     */

    // 
    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid, "",
            ALEventlogConstants.PORTLET_TYPE_EXTTIMECARD);
}

From source file:com.aimluck.eip.modules.screens.ExtTimecardSummaryNewXlsExportScreen.java

License:Open Source License

private void setupTimecardSheet(RunData rundata, Context context, HSSFWorkbook wb) throws Exception {

    ExtTimecardSummaryListSelectData listData = new ExtTimecardSummaryListSelectData();
    listData.init(this, rundata, context);
    listData.setRowsNum(1000);//w w  w . j  a  v a2s .  c  o m
    listData.doViewList(this, rundata, context);
    listData.setuserList(target_group_name);

    String sheet_name = "";
    // ?
    String[] headers = { "???", "", "", "", "", "",
            "", "??", "?", "",
            "", "?", "?", "?",
            "", "?", "", "", "", "",
            "???", "" };
    // 01
    short[] cell_enc_types = { HSSFCell.ENCODING_UTF_16, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.ENCODING_UTF_16, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC, HSSFCell.CELL_TYPE_NUMERIC,
            HSSFCell.CELL_TYPE_NUMERIC };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // ?
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    ExtTimecardSummaryResultData tclistrd = null;
    List<ExtTimecardSummaryResultData> daykeys = listData.getGroupExtTimecards();
    int daykeysize = daykeys.size();
    for (int i = 0; i < daykeysize; i++) {
        tclistrd = daykeys.get(i);

        String user_name = tclistrd.getUserName();// ???
        String year = view_month.substring(0, 4); // 
        String month = view_month.substring(5); // 
        String service_form = tclistrd.getSystemName();// 
        // 
        String total_work_day = tclistrd.getTotalWorkDay().getValueAsString();
        // 
        String official_off_day = tclistrd.getOfficialOffDay().getValueAsString();
        // 
        String statutory_off_day = tclistrd.getStatutoryOffDay().getValueAsString();
        // ??
        String total_work_hour = tclistrd.getTotalWorkHour().getValueAsString();
        // ?
        String work_hour = tclistrd.getWorkHour().getValueAsString();
        // 
        String overtime_statutory_work_hour = tclistrd.getOvertimeWithinStatutoryWorkingHour()
                .getValueAsString();
        // 
        // String overtime_day = tclistrd.getOvertimeDay().getValueAsString();
        String overtime_hour = tclistrd.getOvertimeHour().getValueAsString();
        // ?
        String total_official_off_hour = tclistrd.getTotalOfficialOffHour().getValueAsString();
        // ?
        String total_statutory_off_hour = tclistrd.getTotalStatutoryOffHour().getValueAsString();
        // ?
        String midnight_work_hour = tclistrd.getTotalMidnightWorkHour().getValueAsString();
        // 
        String rest_hour = tclistrd.getRestHour().getValueAsString();
        // String off_day = tclistrd.getOffDay().getValueAsString();// 
        // String off_hour = tclistrd.getOffHour().getValueAsString();// 
        // ?
        String late_coming_day = tclistrd.getLateComingDay().getValueAsString();
        // 
        String early_leaving_day = tclistrd.getEarlyLeavingDay().getValueAsString();
        // 
        String absent_day = tclistrd.getAbsentDay().getValueAsString();
        // 
        String paid_holiday = tclistrd.getPaidHoliday().getValueAsString();
        // 
        String compensatory_holiday = tclistrd.getCompensatoryHoliday().getValueAsString();
        // ???
        String other_day = tclistrd.getOtherDay().getValueAsString();
        // 
        String noinput = tclistrd.getNoInput().getValueAsString();

        String[] rows = { user_name, year, month, service_form, total_work_day, official_off_day,
                statutory_off_day, total_work_hour, work_hour, overtime_statutory_work_hour, overtime_hour,
                total_official_off_hour, total_statutory_off_hour, midnight_work_hour, rest_hour,
                late_coming_day, early_leaving_day, absent_day, paid_holiday, compensatory_holiday, other_day,
                noinput };
        rowcount = rowcount + 1;
        addRow(sheet.createRow(rowcount), cell_enc_types, rows);
    }

    // 
    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance().getEventlogHandler().logXlsScreen(uid, "",
            ALEventlogConstants.PORTLET_TYPE_EXTTIMECARD);
}