如何使用EPPlus在工作表上设置页面布局中断

时间:2016-02-02 18:53:32

标签: c# export-to-excel epplus

有没有办法设置使用EEPlus指定打破页面的位置?我有以下代码设置打印机属性,但没有找到在某个列上设置断点的方法。

import java.util.*;

public class StarterPoker {             
    public static void main(String[] args) 
    {
        do
        {
            System.out.print("Welcome to Starter Poker!\n\n" +
                    "To play, two players will be dealt\n"+
                    "five cards per hand and the hand with\n"+
                    "the highest cards will win. Then you\n"+
                    "will be prompted to continue or quit.\n");
            dealHand();
            findWinner();
        }
        while(playAgain()=='Y');        
    }

    public static void dealHand()
    {
         int p12c=0, p13c=0, p14c=0, p15c=0, p16c=0, p17c=0, p18c=0, p19c=0, p1tc=0, p1jc=0, p1qc=0, p1kc=0, p1ac=0;
         int p22c=0, p23c=0, p24c=0, p25c=0, p26c=0, p27c=0, p28c=0, p29c=0, p2tc=0, p2jc=0, p2qc=0, p2kc=0, p2ac=0;
         int [][] deck        = new int[13][4];
         int [][] player1hand = new int[5][2];
         int [][] player2hand = new int[5][2];  

         //the p1 = player1, then it has each card value, followed by c for count, for example: p12c = player1 2s count.

         String[] suits = {"Spades","Diamonds","Hearts","Clubs"};
         String[] cards = {"2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"};

         Random randGen = new Random();
         do
         {
             String hand1 = "";
             //dealing hand 1
             for(int dex = 0; dex < player1hand.length; dex++)
             {                  
                 boolean goodCard = false;
                 while(!goodCard)
                 {
                     int suit = randGen.nextInt(4);
                     int card = randGen.nextInt(13);

                     if( deck[card][suit] == 0)
                     {
                         goodCard = true;
                         deck[card][suit] = 1;
                         player1hand[dex][0] = suit;
                         player1hand[dex][1] = card;
                         hand1 += "\n     "+cards[card]+" of "+suits[suit]+"";  
                         if(card == 0) p12c=p12c+1;
                         if(card == 1) p13c=p13c+1;
                         if(card == 2) p14c=p14c+1;
                         if(card == 3) p15c=p15c+1;
                         if(card == 4) p16c=p16c+1;
                         if(card == 5) p17c=p17c+1;
                         if(card == 6) p18c=p18c+1;
                         if(card == 7) p19c=p19c+1;
                         if(card == 8) p1tc=p1tc+1;
                         if(card == 9) p1jc=p1jc+1;
                         if(card == 10) p1qc=p1qc+1;
                         if(card == 11) p1kc=p1kc+1;
                         if(card == 12) p1ac=p1ac+1;                            
                     }
                 }
             }  
             String hand2 = "";
             //dealing hand 1
             for(int dex = 0; dex < player2hand.length; dex++)
             {
                 boolean goodCard = false;
                 while(!goodCard)
                 {
                     int suit = randGen.nextInt(4);
                     int card = randGen.nextInt(13);

                     if( deck[card][suit] == 0)
                     {
                         goodCard = true;
                         deck[card][suit] = 1;
                         player2hand[dex][0] = suit;
                         player2hand[dex][1] = card;
                         hand2 += "\n     "+cards[card]+" of "+suits[suit]+"";                              
                         if(card == 0) p22c=p22c+1;
                         if(card == 1) p23c=p23c+1;
                         if(card == 2) p24c=p24c+1;
                         if(card == 3) p25c=p25c+1;
                         if(card == 4) p26c=p26c+1;
                         if(card == 5) p27c=p27c+1;
                         if(card == 6) p28c=p28c+1;
                         if(card == 7) p29c=p29c+1;
                         if(card == 8) p2tc=p2tc+1;
                         if(card == 9) p2jc=p2jc+1;
                         if(card == 10) p2qc=p2qc+1;
                         if(card == 11) p2kc=p2kc+1;
                         if(card == 12) p2ac=p2ac+1;
                     }
                 }
             }                  
             System.out.print("\nDo you want to deal two hands?\nenter 'Y' to continue or anything else to quit: ");        
             Scanner input = new Scanner(System.in);
             char cont = input.next().charAt(0);
             if(cont != 'Y')
             {
                 System.out.println("Program terminated!");
                 System.exit(0);
             }
             System.out.printf("Player 1's hand is %s\n", hand1);
             System.out.printf("Player 2's hand is %s\n", hand2);       
         } while(true);
    }  

    public static void findWinner()
    {
        int p1s = 0, p2s = 0;
        int p1p = 0, p2p = 0;
        int p1t = 0, p2t = 0;
        int p1f = 0, p2f = 0;

        if (p12c > 0)
        {
            if(p12c >1)
            {
                if(p12c > 2)
                {
                    if(p12c > 3)
                    {
                        p1f = 1;
                    }
                    else
                    {
                        p1t = 1;
                    }
                }
                else
                {
                    p1p = p1p+1;
                }
            }
            else
            {
                p1s = p1s+1;
            }           
        }

        if (p13c > 0)
        {
            if(p13c >1)
            {
                if(p13c > 2)
                {
                    if(p13c > 3)
                    {
                        p1f = 1;
                    }
                    else
                    {
                        p1t = 1;
                    }
                }
                else
                {
                    p1p = p1p+1;
                }
            }
            else
            {
                p1s = p1s+1;
            }

        }
        System.out.printf("p1s = %d",p1s);
        //System.out.printf("Player %d wins ", winner);
        //System.out.print("because %d beats %d\n",winCard, loseCard);  
    }

    public static char playAgain(){
        System.out.println("Would you like to play again?");
        Scanner input = new Scanner(System.in);
        char cont = input.next().charAt(0);
        return cont;
    }
}

编辑(这有助于解决我的问题)

UserStoreClient userStoreClient =
  new ClientFactory(evernoteAuth).createUserStoreClient();
userStoreClient.revokeLongSession(evernoteAuth);

1 个答案:

答案 0 :(得分:8)

只需要引用Row和/或Column个对象:

ws.Row(20).PageBreak = true;
ws.Column(2).PageBreak = true;

但请记住,FitToPage可能会压制这些内容。