不好意思,这是客户发的帖加了权限,相关代码我复制出来,仅供你参考思路,因为是C#代码,java的话相关接口得稍作修改
- //根据证书编号分页,复制内页并删除多余部分,每一页为一个sheet
- var innersheet = CoverDescWorkbook.Worksheets[2];
- int usedrow = innersheet.UsedRange.LastRow;
- IRange startrange = innersheet.Range["A1"];
- IRange endrange = innersheet.Range["A1"];
- while (true)
- {
- startrange = endrange;
- endrange=innersheet.UsedRange.Find("证书编号", endrange);
- if (endrange == null)
- {
- var lastsheet=innersheet.Copy();
- lastsheet.Range[7, 0, startrange.Row-7, 1].EntireRow.Delete();
- lastsheet.PageSetup.FitToPagesTall = 1;
- lastsheet.PageSetup.FitToPagesWide = 1;
- break;
- }
-
-
- if (startrange.Row != 0)
- {
- var lastsheet = innersheet.Copy();
- lastsheet.Range[endrange.Row, 0, usedrow - endrange.Row, 1].EntireRow.Delete();
- if(startrange.Row - 7>0)
- lastsheet.Range[7, 0, startrange.Row - 7, 1].EntireRow.Delete();
- lastsheet.PageSetup.IsPercentScale = false;
- lastsheet.PageSetup.FitToPagesTall = 1;
- lastsheet.PageSetup.FitToPagesWide = 1;
- }
- }
- innersheet.Delete();
复制代码
|