1

I am inserting rows in an Excel template from C#. Here is my issue : the row I start my insert with has a solid yellow fill and I need my inserted rows to be white. I am using Interop and have tried a few things but have been unsuccessful. I use a for loop to send these rows, below is my code.

if (((CheckBox)srcAddOnPanel.Controls["chkAddItem" + AddRow]).Checked) //.Checked == false)
  {
    worksheet.Rows[StartAddOn].Insert();
    worksheet.Cells[StartAddOn, "D"].value = srcAddOnPanel.Controls["txtQtyAddOn" + AddRow].Text;
    worksheet.Cells[StartAddOn, "E"].value = srcAddOnPanel.Controls["txtProductNameAddOn" + AddRow].Text;
    worksheet.Cells[StartAddOn, "F"].value = srcAddOnPanel.Controls["txtListPriceAddOn" + AddRow].Text;
    worksheet.Cells[StartAddOn, "G"].value = srcAddOnPanel.Controls["txtMaxDiscountAddOn" + AddRow].Text;
    worksheet.Cells[StartAddOn++, "H"].value = srcAddOnPanel.Controls["txtProposedPriceAddOn" + AddRow].Text;
    }
Anik Islam Abhi
  • 25,137
  • 8
  • 58
  • 80
CamlCase
  • 191
  • 2
  • 2
  • 15

1 Answers1

1

Have a look at Range.Interior.Color Link

Also have a look at this stackoverflow question

Community
  • 1
  • 1
grek40
  • 13,113
  • 1
  • 24
  • 50
  • Ok, this does work,,,somewhat. The only issue I will have is: I wont be able to apply an actual set of cells because what I am sending to excel is dynamic controls so I never know where they are going to land. I use a for loop to send them. – CamlCase Nov 22 '15 at 18:03
  • @CamlCase You can add your actual example code if you want me to have a look at it, but I think at some point you have to convert from abstract controls to concrete cell ranges. So I can't really see your problem there. – grek40 Nov 23 '15 at 06:48