title: IndexOutOfBoundsException in jexcel API
body: <p>I'm having an indexoutofboundsexception, i've scoured the internet and looked at several different solutions, but had no luck with this code. </p>
  
  <p>here is my error message: </p>
  
  <pre><code>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)
  at java.util.ArrayList.get(ArrayList.java:322)
  at jxl.write.biff.WritableWorkbookImpl.getSheet(WritableWorkbookImpl.java:408)
  at Segmentation.main(Segmentation.java:81)
  </code></pre>
  
  <p>line 81: </p>
  
  <pre><code>WritableSheet sheet = copy.getSheet(0); 
  </code></pre>
  
  <p>Some help would be very greatly appreciated. thank you!</p>
  
  <pre><code>import java.io.File; 
  import java.util.Date; 
  import jxl.*; 
  import java.io.IOException;
  import jxl.read.biff.*;
  import jxl.write.*;
  import jxl.Workbook;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.net.MalformedURLException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.net.URL;
  import java.net.URLConnection;
  import java.net.URLEncoder;
  
  public class Segmentation{
  
  
  
      private static  final String googleTranslate = "http://http://translate.google.com/#zh-CN|zh-TW|";
  
      public static String translate(String string) {
  
          String translation = googleTranslate + string;
          URL translationURL;
  
          try { translationURL = new URL(translation); }
          catch(MalformedURLException e) { return e.getMessage(); }
  
          BufferedReader httpin;
          String fullPage = "";
          System.out.println(translation);
          try {
              httpin = new BufferedReader(
                      new InputStreamReader(translationURL.openStream()));
              String line;
              while((line=httpin.readLine()) != null) { fullPage += line + '\n'; }
              httpin.close();
          } catch(IOException e) { return e.getMessage(); }
  
          int begin = fullPage.indexOf("&lt;span class=\"\"&gt;");
          int end = fullPage.indexOf("&lt;/span&gt;");
  
          return fullPage.substring(begin + 15, end);
  
      }
  
  
  public static void main(String[] args) throws IOException, WriteException, BiffException
      {
  
          /*try
          {
              Workbook workbook = Workbook.getWorkbook(new File("DATA_Chinese_All.xls"));
              Sheet sheet = workbook.getSheet(0);
  
  
  
          }
          catch (IOException e)
          {   
              e.printStackTrace();
          }
          catch (BiffException e)
          {
              e.printStackTrace();}*/
  
  
  
              Workbook workbook = Workbook.getWorkbook(new File("DATA_Chinese_All.xls"));
              WorkbookSettings s = new WorkbookSettings();  
              s.setUseTemporaryFileDuringWrite(true);  
              WritableWorkbook copy = Workbook.createWorkbook(new File("someFile.xls"), s);
              //WritableWorkbook copy = Workbook.createWorkbook(new File("output.xls"), workbook);
  
  
              WritableSheet sheet = copy.getSheet(0); 
  
  
  
  
              int max = 302;
              int count = 0;
              for(int i = 1; i &lt; max; i++)
              {   
                  WritableCell cell  = sheet.getWritableCell(1, i);
  
                  if (cell.getType() == CellType.LABEL);
  
                  {
  
                      Label l = (Label) cell;
                      //Result = "http://translate.google.com/#zh-CN|zh-TW|"+(l.getContents();)
                      l.setString(translate(l.getContents()));
  
                      //l.setString();
                  }   
                  count++;
  
              copy.write();
              copy.close();
  
  
  
  
  
  
      } 
  
  
  
  
  }
  }
  </code></pre>