Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Tue Apr 14, 2020 4:08 pm
Hi,
I'm trying to use the drawing functionality in c#.
I found a sample code in the Program guide (Add-arrow-line-to-Excel-worksheet-in-C.html).
However using var line = Sheet.TypedLines.AddLine(); creates the following error 'Cannot assign void to an implicitly-typed variable'
What variable type should i use?
Kind regards,
Perry
-
p.meertens
-
- Posts: 8
- Joined: Tue Sep 23, 2014 8:41 pm
Wed Apr 15, 2020 2:21 am
Hello,
Thanks for your inquiry.
I tested the below code with the latest
Spire.XLS Pack(Hotfix) Version:10.3.8, but didn't encounter any issue. If you are using an older version, please try again with the latest version. If there is still any question, please get back to us.
- Code: Select all
//Initiate a Workbook object and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Add a Double Arrow and fill the line with solid color
var line = sheet.TypedLines.AddLine();
line.Top = 10;
line.Left = 20;
line.Width = 100;
line.Height = 0;
line.Color = Color.Blue;
line.BeginArrowHeadStyle = ShapeArrowStyleType.LineArrow;
line.EndArrowHeadStyle = ShapeArrowStyleType.LineArrow;
//Add an Arrow and fill the line with solid color
var line_1 = sheet.TypedLines.AddLine();
line_1.Top = 50;
line_1.Left = 30;
line_1.Width = 100;
line_1.Height = 100;
line_1.Color = Color.Red;
line_1.BeginArrowHeadStyle = ShapeArrowStyleType.LineNoArrow;
line_1.EndArrowHeadStyle = ShapeArrowStyleType.LineArrow;
//Add an Elbow Arrow Connector
XlsLineShape line3 = sheet.TypedLines.AddLine() as XlsLineShape;
line3.LineShapeType = LineShapeType.ElbowLine;
line3.Width = 30;
line3.Height = 50;
line3.EndArrowHeadStyle = ShapeArrowStyleType.LineArrow;
line3.Top = 100;
line3.Left = 50;
//Add an Elbow Double-Arrow Connector
XlsLineShape line2 = sheet.TypedLines.AddLine() as XlsLineShape;
line2.LineShapeType = LineShapeType.ElbowLine;
line2.Width = 50;
line2.Height = 50;
line2.EndArrowHeadStyle = ShapeArrowStyleType.LineArrow;
line2.BeginArrowHeadStyle = ShapeArrowStyleType.LineArrow;
line2.Left = 120;
line2.Top = 100;
//Add a Curved Arrow Connector
line3 = sheet.TypedLines.AddLine() as XlsLineShape;
line3.LineShapeType = LineShapeType.CurveLine;
line3.Width = 30;
line3.Height = 50;
line3.EndArrowHeadStyle = ShapeArrowStyleType.LineArrowOpen;
line3.Top = 100;
line3.Left = 200;
//Add a Curved Double-Arrow Connector
line2 = sheet.TypedLines.AddLine() as XlsLineShape;
line2.LineShapeType = LineShapeType.CurveLine;
line2.Width = 30;
line2.Height = 50;
line2.EndArrowHeadStyle = ShapeArrowStyleType.LineArrowOpen;
line2.BeginArrowHeadStyle = ShapeArrowStyleType.LineArrowOpen;
line2.Left = 250;
line2.Top = 100;
//Save the file
workbook.SaveToFile("AddLines.xlsx", ExcelVersion.Version2013);
Sincerely,
Rachel
E-iceblue support team
-
rachel.lei
-
- Posts: 1571
- Joined: Tue Jul 09, 2019 2:22 am
Fri Apr 24, 2020 10:10 am
Hello,
Greetings from E-iceblue!
How is your issue now? Could you please give us some feedback at your convenience?
Thanks in advance.
Sincerely,
Rachel
E-iceblue support team
-
rachel.lei
-
- Posts: 1571
- Joined: Tue Jul 09, 2019 2:22 am
Fri Jul 10, 2020 11:37 am
It worked! Thank you
-
p.meertens
-
- Posts: 8
- Joined: Tue Sep 23, 2014 8:41 pm
Mon Jul 13, 2020 1:14 am
Hello,
You are welcome.
Feel free to contact us if you need further assistance.
Have a nice day!
Sincerely,
Rachel
E-iceblue support team
-
rachel.lei
-
- Posts: 1571
- Joined: Tue Jul 09, 2019 2:22 am