SplitVertical + C#

  • Thread starter Thread starter obrienkev
  • Start date Start date
O

obrienkev

Hi,

How do I get data to display in the bottom half of the split pane?

I have 2 separate database queries now and I want the results of the first
one to appear in the top half and the results of the 2nd one to appear in the
bottom half.

Here's my split code...

oWB = (Excel._Workbook)(oXL.Workbooks.Add(System.Reflection.Missing.Value));
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
Excel.Window xlWin = oXL.ActiveWindow;
xlWin.SplitVertical = 216f;

then queryA results...

int rowIndex = 2;

foreach (DataRow row in this.myDataSet1.Tables["myTableAdapter"].Rows)
{
string ExcelAccount = row["Account"].ToString();
string ExcelType = row["Type"].ToString();
string ExcelCurrency = row["Currency"].ToString();

oSheet.Cells[rowIndex, 1] = ExcelnAccount;
oSheet.Cells[rowIndex, 2] = ExcelType;
oSheet.Cells[rowIndex, 3] = ExcelCurrency;
rowIndex++;
}

QueryA should display in the top half only.

QueryB(similar code) should then display in the bottom half only.

Following the below example...

http://support.microsoft.com/kb/302084

Thanks.
 
Kev,

In Excel code, you would use

ActiveWindow.SplitRow = 0
ActiveWindow.SplitRow = 12
ActiveWindow.Panes(1).ScrollRow = 3
ActiveWindow.Panes(2).ScrollRow = 23

With variables, something like this:

lngRowNumOfSplit = 12
lngTopPaneRowNum = 3
lngBottomPaneRowNum = 35

ActiveWindow.SplitRow = 0
ActiveWindow.SplitRow = lngRowNumOfSplit
ActiveWindow.Panes(1).ScrollRow = lngTopPaneRowNum
ActiveWindow.Panes(2).ScrollRow = lngBottomPaneRowNum


How to convert that to C# is up to you.

HTH,
Bernie
MS Excel MVP
 
Back
Top