So Ive creating an Excel sheet with Interop.Excel (I cant use other Librarys).
To load the Data into the Excel sheet is working but the only problem is that one column has Hyperlinks in it and Excel only recognize it as an string and not as an Link.
Because of the bigness of data I load to the sheet I dont use a loop to load every data in. I have like an 2 Array and copy it into my file like this:
Microsoft.Office.Interop.Excel.Range startCell = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 1];
Microsoft.Office.Interop.Excel.Range endCell = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[rows, cols];
Microsoft.Office.Interop.Excel.Range writeRange = worksheet.Range[startCell, endCell];
writeRange.Value = data;
with this way I dont have to wait over 10 minutes to finish the loading.
And with that came the problem that my link will not recognize as Hyperlinks.
I try it with this after ading the writeRange.Value: `
int x = 0;
int range = 2;
foreach (var r in titel)
{
Range range1 = worksheet.Range["F" + range];
range1.Hyperlinks.Add(range1, links[x].ToString(), Type.Missing, Type.Missing, titel[x].ToString());
x++;
range++;
And that is working but its loading over like 4 Minutes and thats to long.
For explanation : Link and titel are string list and they have the link for every row and the titel for display in it.
Now I have try this:
int startRow = 2; // Ändern Sie dies entsprechend Ihrer Daten, wenn die Hyperlinks in Zeile 1 beginnen, verwenden Sie 1
int endRow = startRow + titel.Count - 1;
// Definieren Sie den Bereich, in dem die Hyperlinks als Formeln erstellt werden sollen
Range formulaRange = (Range)worksheet.Range[worksheet.Cells[startRow, 6], worksheet.Cells[endRow, 6]];
formulaRange.NumberFormat = "General";
}`
with that I get the range of the desired Column which I want to make a Hyperlink Formate.
And tried to set the format it self but that didnt worked.
Then I tried this:
string formula = "=HYPERLINK(\"" + titel[0] + "\")";
formulaRange.Formula = formula;
and this made the column to an Hyperlink but with the wrong link cleary.
So my question is how is it possibly to achieve it that I can format the whole column for an Formular or an Hyperlink without looping through every cell. Like I just set the column in the right formular.