You must Sign In to post a response.
  • Category: .NET

    Insert array into excel using vb.net

    Hello,

    I want to insert array into alternative column of each row into excel using excel.range in vb.net.
    Answer it ASAP.

    Note: Do not use for loop or for each or iteration

    Thanks & Regards,
    Mahendiran
  • #764052
    Hai Mahendiran,
    I think you can use the Office Interop to write in to the Excel file as:

    using Microsoft.Office.Interop;
    Excel.Application excelApplication = new Excel.Application();
    Workbook wb = excelApplication.Workbook.Add();
    Worksheet ws = wb.Worksheets.Item[1];
    FormatCondition format = ws.Rows.FormatConditions.Add(XlFormatConditionType.xlExpression, XLFormatConditionOperator.xlEqual, "=MOD(ROW(),2) = 0");
    // write the code to set the values from the array.

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #764061
    Dear Pawan Awasthi,

    Thanks for your support,

    I want to insert array into alternative cell

    eg.insert value in alternative cell ie K,M,O,Q...cell

    Thanks & Regards
    Mahendiran.B

  • #764093
    Hi there,

    Can you split your array to several arrays? If you can split your array to several arrays, then you can insert each of them to the specific column by using sheet.InsertArray(string[] stringArray, int firstRow, int firstColumn, bool isVertical) method which is provided by Spire.XLS component. And this is a overloaded function that can fulfill your different requirements of inserting data from array to columns or rows in Excel.

    http://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Set-an-Array-of-Values-into-a-Range-in-Excel-Worksheet.html


Sign In to post your comments