MSDN > フォーラム ホーム > Visual Studio Tools for Office > How to fill a Range from an array in vsto and excel 2003
質問する質問する
 

回答済みHow to fill a Range from an array in vsto and excel 2003

  • 2007年12月5日 23:26MaxJC ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Hi

     

    I'd appreciate if someone shows me how to fill an excel range with an array data using vsto and visual basic, with one or two lines of code (not cell by cell).

     

    My array and my range look like A(2000, 25) and Range("A11:Z2000)

     

    Thank you very much!

    Max

     

     

回答

  • 2007年12月6日 7:37Ji.ZhouMSFT, モデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Hi,

     

    There are two ways to do that. One is using 2D array, and another is using Application.WorkbookFunction.Transpose(array)

    A very good blog article and followed discussions are available in Eric Carter’s blog:

    http://blogs.msdn.com/eric_carter/archive/2004/05/04/126190.aspx

    Codes work fine in my side:

    Code Block

                int[] arr = new int[5];
                arr[0] = 0;
                arr[1] = 1;
                arr[2] = 2;
                arr[3] = 3;
                arr[4] = 4;

                app.get_Range("A1", "A5").Value2 = app.WorksheetFunction.Transpose(arr);

     

     

     

     

     

    Thanks

    Ji

     

  • 2007年12月6日 18:58MaxJC ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Ji:

    It worked well !

    Thank you very much Ji

    Max

すべての返信

  • 2007年12月6日 7:37Ji.ZhouMSFT, モデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Hi,

     

    There are two ways to do that. One is using 2D array, and another is using Application.WorkbookFunction.Transpose(array)

    A very good blog article and followed discussions are available in Eric Carter’s blog:

    http://blogs.msdn.com/eric_carter/archive/2004/05/04/126190.aspx

    Codes work fine in my side:

    Code Block

                int[] arr = new int[5];
                arr[0] = 0;
                arr[1] = 1;
                arr[2] = 2;
                arr[3] = 3;
                arr[4] = 4;

                app.get_Range("A1", "A5").Value2 = app.WorksheetFunction.Transpose(arr);

     

     

     

     

     

    Thanks

    Ji

     

  • 2007年12月6日 18:58MaxJC ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Ji:

    It worked well !

    Thank you very much Ji

    Max