S
serhio
Hello,
I am new in Office programming, and I wonder how to select in the best way
the groups of "used" empty cells from the first column A.
A B C
1 X X
2 X
--------
3 X
4 X X
--------
5 X
6 X
7 X X
8 X X
--------
9 X
10 X
11 X
12 X
..............
Well, I would like to group the rows, leaving the A column value as group
name.
I need to identify the lower valued cell in all columns, and the non empty
cells in the "A" column.
Is there a possibility to do it "quick" in .NET (C#)?
CODE SNIPPET
// The following code opens an existing workbook
string workbookPath = @"C:\MyFile.xls"; // Add your own path here
Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, XlPlatform.xlWindows, "", true,
false, 0, true, false, false);
// The following gets the Worksheets collection
Sheets excelSheets = excelWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelWorksheet =
(Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(1);
excelWorksheet.Outline.SummaryRow = XlSummaryRow.xlSummaryAbove;
Range excelCell = (Range)excelWorksheet.get_Range("A1",
Missing.Value);
excelCell.get_End(XlDirection.xlDown).get_Address ;
string downAddress = excelCell.get_Address(
false, false, XlReferenceStyle.xlA1,
Type.Missing, Type.Missing);
excelCell = excelWorksheet.get_Range("A1", downAddress);
Probably, I must use the get_Range and get_End functions; also the UsedRange
property should give me the entire range, with all the empty cells, but not
quite sure what to do from here...
I am new in Office programming, and I wonder how to select in the best way
the groups of "used" empty cells from the first column A.
A B C
1 X X
2 X
--------
3 X
4 X X
--------
5 X
6 X
7 X X
8 X X
--------
9 X
10 X
11 X
12 X
..............
Well, I would like to group the rows, leaving the A column value as group
name.
I need to identify the lower valued cell in all columns, and the non empty
cells in the "A" column.
Is there a possibility to do it "quick" in .NET (C#)?
CODE SNIPPET
// The following code opens an existing workbook
string workbookPath = @"C:\MyFile.xls"; // Add your own path here
Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, XlPlatform.xlWindows, "", true,
false, 0, true, false, false);
// The following gets the Worksheets collection
Sheets excelSheets = excelWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelWorksheet =
(Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(1);
excelWorksheet.Outline.SummaryRow = XlSummaryRow.xlSummaryAbove;
Range excelCell = (Range)excelWorksheet.get_Range("A1",
Missing.Value);
excelCell.get_End(XlDirection.xlDown).get_Address ;
string downAddress = excelCell.get_Address(
false, false, XlReferenceStyle.xlA1,
Type.Missing, Type.Missing);
excelCell = excelWorksheet.get_Range("A1", downAddress);
Probably, I must use the get_Range and get_End functions; also the UsedRange
property should give me the entire range, with all the empty cells, but not
quite sure what to do from here...