Ejemplo n.º 1
0
        public void TestDoubleValue()
        {
            //put cell names in vars...

            var        excelFile = ExcelFile.Open(path);
            IWorksheet worksheet = excelFile.OpenWorksheet(sheetName);

            var cellLowerCase = worksheet.GetCell("c3");

            Assert.NotNull(cellLowerCase);

            var doubleValueCell = worksheet.GetCell("A4");

            Assert.NotNull(doubleValueCell);
            doubleValueCell.DoubleValue = doubleValue;

            var stringValueCell = worksheet.GetCell("A5");

            Assert.NotNull(stringValueCell);
            stringValueCell.StringValue = stringValue;

            var fakeStringValueCell = worksheet.GetCell("A6");

            Assert.NotNull(fakeStringValueCell);
            fakeStringValueCell.StringValue = fakeStringValue;

            var charNumberValueCell = worksheet.GetCell("A7");

            Assert.NotNull(charNumberValueCell);
            charNumberValueCell.DoubleValue = charNumber;
            excelFile.Save();
            excelFile.Close();
        }
Ejemplo n.º 2
0
        public void TestWriteNullValueCell()
        {
            var        excelFile = ExcelFile.Open(path);
            IWorksheet worksheet = excelFile.OpenWorksheet(sheetName);
            var        cellName  = "D19";

            worksheet.GetCell(cellName).StringValue = null;

            excelFile.Save();

            Assert.Null(worksheet.GetCell(cellName).StringValue);
        }
Ejemplo n.º 3
0
        private void AddTitle(IWorksheet worksheet)
        {
            _rowIndex++;
            worksheet.GetCell(_rowIndex, 1).Value = _title;
            var range = worksheet.GetCellRange(_rowIndex, 1, _rowIndex, 2);

            range.Style.Font.Bold = true;
            range.Style.Font.Size = 16;

            // datum / User
            worksheet.GetCell(_rowIndex, 4).Value = string.Format("{0:G}", DateTime.Now);
            worksheet.GetCell(_rowIndex, 5).Value = ApplicationContext.User.Identity.Name;

            // leer Zeile
            _rowIndex++;
        }
Ejemplo n.º 4
0
        private void AddParams(IWorksheet worksheet)
        {
            var startRow = _rowIndex + 1;

            foreach (var parameter in _parameters)
            {
                _rowIndex++;
                worksheet.GetCell(_rowIndex, 1).Value = parameter.Key;
                worksheet.GetCell(_rowIndex, 2).Value = parameter.Value;
            }
            var range = worksheet.GetCellRange(startRow, 1, _rowIndex, 1);

            range.Style.Font.Bold = true;

            // leer Zeile
            _rowIndex++;
        }
Ejemplo n.º 5
0
        public void TestWriteStringAtCell()
        {
            var cellName  = "D18";
            var cellValue = "Peteca";

            var        excelFile = ExcelFile.Open(path);
            IWorksheet worksheet = excelFile.OpenWorksheet(sheetName);

            worksheet.GetCell(cellName).StringValue = cellValue;

            //excelFile.Save();
            //excelFile.Close();

            //excelFile = ExcelFile.Open(path);
            //worksheet = excelFile.OpenWorksheet(sheetName);

            Assert.Equal(cellValue, worksheet.GetCell(cellName).StringValue);
            excelFile.Close();
        }
Ejemplo n.º 6
0
        private void AddHeadings(IWorksheet worksheet)
        {
            _rowIndex++;
            for (int c = 0; c < _numOfCols; c++)
            {
                worksheet.GetCell(_rowIndex, c + 1).Value = _gridView.VisibleColumns[c].Caption;
            }
            var range = worksheet.GetCellRange(_rowIndex, 1, _rowIndex, _numOfCols);

            range.Style.Fill.PatternType     = EFillStyle.Solid;
            range.Style.Fill.BackgroundColor = Color.LightGray;
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            ExcelFile  file   = ExcelFile.Open(@"D:\Book1.xlsx");
            IWorksheet sheet2 = file.OpenWorksheet("asasda");
            IWorksheet sheet1 = file.OpenWorksheet("Sheet1");
            var        cell   = sheet1.GetCell("A4");


            //IWorksheet sheet1 = file.OpenWorksheet("Sheet2");

            //Column a = sheet1.CreateColumnBetween(8, 8);


            //Column column = sheet1.GetColumn("F");
            //double realPosition = sheet1.GetColumnPosition(column.ColumnIndex);
            //Row row = sheet1.GetRow(12);
            //double rowRealPosition = sheet1.GetRowPosition(row.Index);

            //column.Width = 4.57;

            /*
             * //Numbers
             * Cell h1 = sheet1.GetCell("H1"); //Cell in use.
             * h1.Value = "40210";
             * Cell c1 = sheet1.GetCell("C1");
             * c1.Value = "3443";
             *
             * //Text
             * Cell b1 = sheet1.GetCell("B1");
             * b1.Value = "Atwood Falcon"; //Existing text - index = 7;
             * Cell a3 = sheet1.GetCell("A3");
             * a3.Value = "New Text for A3"; //new Text
             */

            /*var shape = sheet1.Drawings.DrawShape(sheet1.GetColumn("D"), sheet1.GetRow(4), 0, 0, 40, 80);
             * shape.Text = "Shape1";
             * shape.ForeColor = Color.Black;
             * shape.MarginLeft = 10;
             * shape.MarginRight = 10;
             * shape.MarginTop = 10;
             * shape.MarginBottom = 10;
             * shape.Text = "12345";*/

            file.Save();
            file.Close();
        }
Ejemplo n.º 8
0
 // in this context a cell is treated as empty if there is now key defined
 private bool IsEmptyRow(int row)
 {
     return(mySheet.IsEmptyCell(mySheet.GetCell("A" + row)));
 }