using System; using System.Text; using System.IO; using NPOI.HSSF.UserModel; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using NPOI.SS.UserModel; namespace DrawingInXls { class Program { static void Main(string[] args) { InitializeWorkbook(); Sheet sheet1 = hssfworkbook.CreateSheet("new sheet"); Sheet sheet2 = hssfworkbook.CreateSheet("second sheet"); Sheet sheet3 = hssfworkbook.CreateSheet("third sheet"); Sheet sheet4 = hssfworkbook.CreateSheet("fourth sheet"); // Draw stuff in them DrawSheet1(sheet1); DrawSheet2(sheet2); DrawSheet3(sheet3); DrawSheet4(sheet4, hssfworkbook); WriteToFile(); } private static void DrawSheet1(Sheet sheet1) { // Create a row and size one of the cells reasonably large. Row row = sheet1.CreateRow(2); row.Height = ((short)2800); row.CreateCell(1); sheet1.SetColumnWidth(2, 9000); // Create the Drawing patriarch. This is the top level container for // all shapes. HSSFPatriarch patriarch = (HSSFPatriarch)sheet1.CreateDrawingPatriarch(); // Draw some lines and an oval. DrawLinesToCenter(patriarch); DrawManyLines(patriarch); DrawOval(patriarch); DrawPolygon(patriarch); // Draw a rectangle. HSSFSimpleShape rect = patriarch.CreateSimpleShape(new HSSFClientAnchor(100, 100, 900, 200, (short)0, 0, (short)0, 0)); rect.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_RECTANGLE); } private static void DrawSheet2(Sheet sheet2) { // Create a row and size one of the cells reasonably large. Row row = sheet2.CreateRow(2); row.CreateCell(1); row.HeightInPoints = 240; sheet2.SetColumnWidth(2, 9000); // Create the Drawing patriarch. This is the top level container for // all shapes. This will clear out any existing shapes for that sheet. HS