Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete the entire row or column in excel #157

Open
GoogleCodeExporter opened this issue Sep 9, 2015 · 2 comments
Open

How to delete the entire row or column in excel #157

GoogleCodeExporter opened this issue Sep 9, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by pradipku...@gmail.com on 28 Nov 2013 at 12:52

@GoogleCodeExporter
Copy link
Author

I cant find any delete method on GetRow(x). How to a row in Excel worksheet ?

Im using: ExcelLibrary_20110730.zip
OS: Windows 7 Premium

Original comment by maxis...@gmail.com on 10 Jun 2015 at 9:58

@GoogleCodeExporter
Copy link
Author

A way to delete a row.

private void RemoveRecord(int index)
        {
            Workbook book = Workbook.Load(excel_filename);
            Worksheet _sheet = book.Worksheets[0];
            Worksheet _newsheet = new Worksheet(_sheet.Name);

            for (int i = _sheet.Cells.FirstRowIndex; i <= _sheet.Cells.LastRowIndex; i++)
            {
                if(i != index)
                {
                    int lastRow = _newsheet.Cells.Rows.Count;
                    for (int col_index = _sheet.Cells.FirstColIndex; col_index <= _sheet.Cells.LastColIndex; col_index++ )
                    {
                        _newsheet.Cells[lastRow, col_index] = new Cell(_sheet.Cells[i, col_index].StringValue);
                    }
                }
            }

            book.Worksheets.RemoveAt(0);
            _newsheet.Book = book;

            book.Worksheets.Add(_newsheet);
            book.Save(excel_filename);
        }

Original comment by maxis...@gmail.com on 10 Jun 2015 at 1:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant