Problem to correct the lines

Hi,

What are the equivalent syntax to these
ws.Cell(1, 1).Style.Font.Bold = true;
ws.Cell(1, 1).Style.Fill.BackgroundColor = XLColor.Red;

Open in new window


in VS 2013 C#, as now I cannot choose "Style"

to

worksheet.Cells[1,1], now?

How to resolve this
Error	1	The type or namespace name 'Range' could not be found (are you missing a using directive or an assembly reference?)

Open in new window



to this line?
Range rg = (Excel.Range) worksheet.Cells[1, 1];

Open in new window

LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
You need to add reference to Microsoft.Office.Interop.Excel.dll, and then a translated code from ExcelPackage to Excel Automation is:
ws.Cells(1, 1).Font.Bold = true;
ws.Cells(1, 1).Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

Open in new window

0
HuaMin ChenProblem resolverAuthor Commented:
Sorry, I get the error below, to the codes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;
...
            worksheet.Cells[1, 1].Font.Bold = true;
            worksheet.Cells[1, 1].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
            ...

Open in new window

Error	1	The type or namespace name 'ColorTranslator' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)
Error	2	The type or namespace name 'Color' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)

Open in new window

0
Duy PhamFreelance IT ConsultantCommented:
Do you have reference to System.Drawing.dll in your project? Both Color and ColorTranslator are supported in all versions of System.Drawing.dll (up to 4.5), so as long as you have added to that dll in your project, build will be ok.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
Thanks. I'm already using these

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;
...

Open in new window

how to ensure

System.Drawing

is 4.5?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.