I have created an excelsheet using interoperabilty.I need to add array in to the first position and all other column need to move
this is how i tried and not working.any way?
C#
Excel.Range rng = xlWorkSheet.get_Range("A1", misValue);
string[] result = File.ReadAllLines(path);
rng.Value2 = result;
rng.EntireColumn.Insert(Excel.XlInsertShiftDirection.xlShiftToRight,
Excel.XlInsertFormatOrigin.xlFormatFromRightOrBelow);
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Dec 12, 2021, 8:13 AM EST
Leon DRank #851 · 2.6K reputationPosted Dec 12, 2021, 8:13 PM EST
You can use Free Spire.XLS library to insert array into an Excel worksheet.
Here is a basic example:
using Spire.Xls; namespace SetArrayofValues { class Program { private void SetArrayValueExample() { Workbook workbook = new Workbook(); workbook.CreateEmptySheets(1); Worksheet sheet = workbook.Worksheets[0]; int maxRow = 10000; //int maxRow = 5; int maxCol = 200; //int maxCol = 5; object[,] myarray = new object[maxRow + 1, maxCol + 1]; bool[,] isred = new bool[maxRow + 1, maxCol + 1]; for (int i = 0; i 8) isred[i, j] = true; } sheet.InsertArray(myarray, 1, 1); workbook.SaveToFile("test.xls",ExcelVersion.Version97to2003); } } }For more information, check this link:
https://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Set-an-Array-of-Values-into-a-Range-in-Excel-Worksheet.html