How to create a excel output using this shape Parallelogram below attached image like

@amjad.sahi, @Professionalize.Discourse, @John.He, @simon.zhao

image.png (101.6 KB)

How to same end of bottom-right point and top-right point like above image.

double w = chartWidth;
double h = 13.5;

Shape notPrimitiveShape = worksheet.Shapes.AddAutoShape(AutoShapeType.Parallelogram, 0, 0, 0, 0, 0, 0);
notPrimitiveShape.WidthPt = chartWidth * widthInPoints;
notPrimitiveShape.HeightPt = h;
notPrimitiveShape.X = (int)((xx1 + chartX) + 5);
notPrimitiveShape.Y = (int)(Top + chartYPosition);

@imparthgalani

Cause

To create a parallelogram shape in Excel using Aspose.Cells, you need to set the appropriate properties for the shape, including its dimensions and position. The goal is to ensure that the bottom-right and top-right points are aligned as shown in your reference image.

Solution

You can achieve this by using the AddShape method to create a parallelogram and then adjusting its properties such as position and size. Here’s how you can do it:

Code

Here’s a sample code snippet to create a parallelogram shape in an Excel worksheet:

using Aspose.Cells;
using Aspose.Cells.Drawing;

class Program
{
    static void Main()
    {
        // Create a new workbook
        Workbook workbook = new Workbook();
        Worksheet worksheet = workbook.Worksheets[0];

        // Define the position and size of the parallelogram
        int upperLeftRow = 5;
        int upperLeftColumn = 2;
        int lowerRightRow = 10;
        int lowerRightColumn = 5;

        // Add a parallelogram shape
        Shape parallelogram = worksheet.Shapes.AddShape(ShapeType.Parallelogram, upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn);

        // Set the fill color
        parallelogram.FillFormat.FillType = FillType.Solid;
        parallelogram.FillFormat.SolidFill.Color = System.Drawing.Color.Blue;

        // Optionally, set the line format
        parallelogram.LineFormat.IsVisible = true;
        parallelogram.LineFormat.Color = System.Drawing.Color.Black;
        parallelogram.LineFormat.Weight = 2;

        // Save the workbook
        workbook.Save("ParallelogramExample.xlsx");
    }
}

Next Steps

  1. Adjust the upperLeftRow, upperLeftColumn, lowerRightRow, and lowerRightColumn values to position the parallelogram as needed.
  2. Customize the fill and line formats to match your design requirements.
  3. Run the code to generate the Excel file and verify the shape’s appearance.

If you have any further questions or need additional assistance, feel free to ask!

This will not work like above image

@duojie.yang , @duojie.yang.aspose

How to edit this parallelogram shape, all points are pixel custom points.

@imparthgalani
Please refer to the following example code.

ShapePath shapePath = new ShapePath();
shapePath.MoveTo(15, 0);
shapePath.LineTo(230, 0);
shapePath.LineTo(230, 15);
shapePath.LineTo(0, 15);
shapePath.Close();

int w = 230, h = 15;//The width and height values ​​are set to the image size represented by the ShapePath object you defined above.
Workbook workbook = new Workbook();
Shape shape = workbook.Worksheets[0].Shapes.AddFreeform(1, 0, 1, 0, h, w, new ShapePath[] { shapePath });
shape.Line.FillType = FillType.Solid;
shape.Line.SolidFill.Color = Color.FromArgb(255, 0, 0);
shape.Fill.FillType = FillType.Solid;
shape.Fill.SolidFill.Color = Color.FromArgb(255, 255, 204);
workbook.Save("out_net.xlsx", SaveFormat.Xlsx);

In addition, parallelogram shapes cannot be changed to the shape you need. If the shape you need differs from the standard shape, we strongly recommend using the AddFreeform method to add the shape.

1 Like

@John.He,

Thanks for the quick reply. This problem will be solved.

@imparthgalani
Thank you for your feedback. You are welcome. I’m glad your issue has been resolved. If you have any questions, please feel free to contact us at any time.