C# 用NPOI 在excel中画一条直线,设置的偏移量不起作用?

一个最萌的对手 发布于 2018/03/28 08:50
阅读 437
收藏 0

我通过NPOI对excel操作,有两个单元格 单元格内有值,我想在这两个单元格之间画一条直线,直线可以画,但是设置的偏移量不起作用

private void drawLine()
        {
            FileStream fileStream = new FileStream(fileShortName, FileMode.Open, FileAccess.Read);
            XSSFWorkbook xssfWorkBook = new XSSFWorkbook(fileStream);  //xls数据读入workbook  
            XSSFSheet sheet = (XSSFSheet)xssfWorkBook.GetSheetAt(0);
            int lastrow = sheet.LastRowNum;
            int color1 = 0;
            int color2 = 0;
            
            XSSFDrawing patriarch = (XSSFDrawing)sheet.CreateDrawingPatriarch();
            XSSFClientAnchor regionr = null;
            XSSFSimpleShape region1Shapevr = null;

            //regionr = new XSSFClientAnchor(0,0,0,0,20,2,11,3);
            if(row[0] > row[2])
            {
                regionr = new XSSFClientAnchor(525, 210, 525, 25, row[2], lastrow, row[0] + 1, lastrow - 1);
            }
            else
            {
                regionr = new XSSFClientAnchor(525, 25, 525, 210, row[0] + 1, lastrow - 1, row[2], lastrow);
            }
            region1Shapevr = patriarch.CreateSimpleShape(regionr);
            region1Shapevr.SetShapeType(1);
            region1Shapevr.LineWidth = 2;
         
           
            FileStream fileStream1 = File.Create(fileShortName);
            xssfWorkBook.Write(fileStream1);
            fileStream.Close();
            fileStream1.Close();
        }

 

加载中
返回顶部
顶部