Ejemplo n.º 1
0
        private void AppendToXlscell(ReportFile RF)
        {
            ISheet       sheet1       = RF.hssfworkbook.GetSheet("Sheet1");
            int          RowCount     = sheet1.LastRowNum + 1;
            HSSFWorkbook hssfworkbook = new HSSFWorkbook();
            ICellStyle   cellstyle    = hssfworkbook.CreateCellStyle();

            cellstyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderTop    = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderLeft   = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderRight  = NPOI.SS.UserModel.BorderStyle.Thin;
            IRow newRow = sheet1.CreateRow(RowCount);

            for (int i = 0; i < 13; i++)
            {
                ICell cell = newRow.CreateCell(i);
                cell.SetCellValue((string)RFcolumns.GetType().GetFields()[i].GetValue(RFcolumns));
                cell.CellStyle = cellstyle;
                if (i == 5 | i == 6)
                {
                    cell.CellStyle.WrapText = true;
                }
            }
            sheet1.ForceFormulaRecalculation = true;
            RF.WriteToFile();
        }
Ejemplo n.º 2
0
        public XlsContentProcess(string path)
        {
            savePath = path == null?savePath:path;
            byte[] filebuffer = Properties.Resources.baseXLSRes;
            Stream filestream = new MemoryStream(filebuffer);

            reportfile = new ReportFile(filestream);
            // ISheet sheet = sourceWB.GetSheet("Sheet1");
        }
Ejemplo n.º 3
0
        private void AppendToXlscell(ReportFile RF, int index, ReportFileColumns RFC)
        {
            ISheet sheet1   = RF.hssfworkbook.GetSheet("Sheet1");
            int    Rowindex = index;
            IRow   newRow   = sheet1.CreateRow(Rowindex);

            newRow.HeightInPoints = 20;
            ICellStyle cellstyle = RF.hssfworkbook.CreateCellStyle();

            cellstyle.BorderBottom      = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderTop         = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderLeft        = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.BorderRight       = NPOI.SS.UserModel.BorderStyle.Thin;
            cellstyle.VerticalAlignment = VerticalAlignment.Center;
            //  ICellStyle DatecellStype = RF.hssfworkbook.CreateCellStyle();
            // IDataFormat format = RF.hssfworkbook.CreateDataFormat();
            for (int i = 0; i < 13; i++)
            {
                ICell cell = newRow.CreateCell(i);

                cell.SetCellValue((string)RFC.GetType().GetFields()[i].GetValue(RFC));
                cell.CellStyle = cellstyle;

                /*  if (i == 10)
                 * {
                 *    cell.SetCellValue((DateTime)RFC.GetType().GetFields()[i].GetValue(RFC));
                 *
                 *    DatecellStype.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
                 *    DatecellStype.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
                 *    DatecellStype.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
                 *    DatecellStype.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
                 *    DatecellStype.VerticalAlignment = VerticalAlignment.Center;
                 *    DatecellStype.DataFormat = format.GetFormat("m/d/yy");
                 *    cell.CellStyle = DatecellStype;
                 *    // cell.CellStyle.WrapText = true;
                 * }
                 * else
                 * {*/
            }
            sheet1.ForceFormulaRecalculation = true;
        }