EDN Admin
Well-known member
Hello,
I have searched the Internet for over an hour and I cannot find a solution to this. The closest I came was that someone was able to pull an individual cells background color from Excel, and save it as a double. I can do this, but this is not
what I need for my application.
What I need is to pull a range of background color values from Excel. Everytime I try this, and save it to a double[] array, I get this error:
<span style="font-size:x-small
<span style="text-decoration:underline An exception occurred: Unable to cast object of type System.Double to type System.Double[]
Here is a snippet from my code. If anyone can help me with this, I would greatly appreciate it! This code is for a Production hours calendar where each day of the year (from a calendar in excel...each date is a separate cell) can be highlighted
with a different background color. This color then corresponds to a Shift Hour work time (example, BG color blue = 8 hours, White = 9 hours, etc...).<span style="font-size:small
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small double<span style="font-size:small [] colorRange;<span style="font-size:small
<span style="font-size:small
<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small DataSet<span style="font-size:small dateRangeDS =
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small new<span style="font-size:small
<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small DataSet<span style="font-size:small ();<span style="font-size:small
<span style="font-size:small
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small for<span style="font-size:small (<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small int<span style="font-size:small
monthOfYearCount = 1; monthOfYearCount <= <span style="color:#008080; font-size:small <span style="color:#008080; font-size:small Convert<span style="font-size:small .ToInt32(startDateMonthParse.ToString()); monthOfYearCount++)<span style="font-size:small
<span style="font-size:small
{
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small if<span style="font-size:small (monthOfYearCount==1)<span style="font-size:small
<span style="font-size:small
{
startDateRange1 = (System.<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small Array<span style="font-size:small )ObjWorkSheet_ShiftDates.get_Range(<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "D7"<span style="font-size:small ,
<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "J11"<span style="font-size:small ).Cells.Value2;
<span style="font-size:small
//Here is where my code bombs out (double[] colorRange). This is where I want to pull an Array of background color values.
colorRange = (<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small double<span style="font-size:small [])ObjWorkSheet_ShiftDates.get_Range(<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "D7"<span style="font-size:small ,
<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "J11"<span style="font-size:small ).Interior.Color;<span style="font-size:small
<span style="font-size:small
}
<a> <a>
<
RB
<br/>
<br/>
<br/>
View the full article
I have searched the Internet for over an hour and I cannot find a solution to this. The closest I came was that someone was able to pull an individual cells background color from Excel, and save it as a double. I can do this, but this is not
what I need for my application.
What I need is to pull a range of background color values from Excel. Everytime I try this, and save it to a double[] array, I get this error:
<span style="font-size:x-small
<span style="text-decoration:underline An exception occurred: Unable to cast object of type System.Double to type System.Double[]
Here is a snippet from my code. If anyone can help me with this, I would greatly appreciate it! This code is for a Production hours calendar where each day of the year (from a calendar in excel...each date is a separate cell) can be highlighted
with a different background color. This color then corresponds to a Shift Hour work time (example, BG color blue = 8 hours, White = 9 hours, etc...).<span style="font-size:small
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small double<span style="font-size:small [] colorRange;<span style="font-size:small
<span style="font-size:small
<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small DataSet<span style="font-size:small dateRangeDS =
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small new<span style="font-size:small
<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small DataSet<span style="font-size:small ();<span style="font-size:small
<span style="font-size:small
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small for<span style="font-size:small (<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small int<span style="font-size:small
monthOfYearCount = 1; monthOfYearCount <= <span style="color:#008080; font-size:small <span style="color:#008080; font-size:small Convert<span style="font-size:small .ToInt32(startDateMonthParse.ToString()); monthOfYearCount++)<span style="font-size:small
<span style="font-size:small
{
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small if<span style="font-size:small (monthOfYearCount==1)<span style="font-size:small
<span style="font-size:small
{
startDateRange1 = (System.<span style="color:#008080; font-size:small <span style="color:#008080; font-size:small Array<span style="font-size:small )ObjWorkSheet_ShiftDates.get_Range(<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "D7"<span style="font-size:small ,
<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "J11"<span style="font-size:small ).Cells.Value2;
<span style="font-size:small
//Here is where my code bombs out (double[] colorRange). This is where I want to pull an Array of background color values.
colorRange = (<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small double<span style="font-size:small [])ObjWorkSheet_ShiftDates.get_Range(<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "D7"<span style="font-size:small ,
<span style="color:#800000; font-size:small <span style="color:#800000; font-size:small "J11"<span style="font-size:small ).Interior.Color;<span style="font-size:small
<span style="font-size:small
}
<a> <a>
<
RB
<br/>
<br/>
<br/>
View the full article