Report Development using C # and Excel (6)

Source: Internet
Author: User

In Excel, rows and columns are actually still range, but the way to get rows and columns is somewhat different from the previous essays, to use the Get_item method of the rows and columns properties of worksheet, the following is an example code that shows how to select rows. and copy the data between the rows, and insert the row:

ThisApplication = new Excel.Application ();
ThisWorkbook = ThisApplication.Workbooks.Open ("Z:\\book1.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Thisapplication.displayalerts = false;
Xlsheet = (Excel.Worksheet) ThisWorkbook.Worksheets.get_Item (1);
Excel.Range Range = Xlsheet.get_range ("G4", Type.Missing);
Excel.Range Range  = (excel.range) xlSheet.Rows.get_Item (%, type.missing);
Excel.Range Range1 = (excel.range) xlSheet.Rows.get_Item (type.missing);
Range. Value = "123";
Range. Copy (range1);
Range1. Rows.insert (Xlinsertshiftdirection.xlshiftdown);
Thisworkbook.saveas ("Z:\\book2.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing,
             Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange,
             Type.Missing, Type.Missing, Type.Missing, Type.Missing);

About the release of the Excel process, the previous essays have been, here will not repeat.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.