Create an Excel file using Excel libraray

 private void button9_Click(object sender, EventArgs e)
        {
            string file = "E:\\" + "newdoc" + DateTime.Now.Millisecond + ".xls";
            Workbook workbook = new Workbook();
            Worksheet worksheet = new Worksheet("First Sheet");
            worksheet.Cells[0, 1] = new Cell((short)1);
            worksheet.Cells[2, 0] = new Cell(2.8);
            worksheet.Cells[3, 3] = new Cell((decimal)3.45);
            worksheet.Cells[2, 2] = new Cell("Text sduplicated across each Web server in the farm.");
            worksheet.Cells[2, 4] = new Cell("Second string");
            worksheet.Cells[4, 0] = new Cell(32764.5, "#,##0.00");
            worksheet.Cells[5, 1] = new Cell(DateTime.Now, @"YYYY\-MM\-DD");
            worksheet.Cells[1, 1] = new Cell("http://www.gooogle.com");
            worksheet.Cells.ColumnWidth[0, 1] = 3000;
            //Picture pic = new Picture();
            //pic.Image = Excel.Image.FromFile("C:\\DelBreakpoint.png");
            //pic.TopLeftCorner = new CellAnchor(5, 1, 0, 0);
            //pic.BottomRightCorner = new CellAnchor(12, 5, 592, 243);
            //worksheet.AddPicture(pic);
            workbook.Worksheets.Add(worksheet);
            workbook.Save(file);
            //open created file
            doc = CompoundDocument.Open(file);
            IsOpened = true;
            ////PopulateTreeview(file);

        }



here i reqest you to maintain a file size is atlest 5 kb unless you cant see the out put if cop an past the simple code it just 3 kb so the screeen is blank ples fill upto 5kb atlest.......

Comments

Popular posts from this blog

My Interview Experience

React Checkbox Control SPFx