Showing posts with label developing. Show all posts
Showing posts with label developing. Show all posts

Tuesday, 14 September 2010

How to use xls ( Excel ) files in Java

How to use xls (Excel) files in Java

First, you need the POI library. You can download it here.


To work with a xls File with Java is very easy. Simply, you have to fix in Rows and Cells.













I show you a part of source code, it's more easy to understand.

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Workbook wb = new XSSFWorkbook();
FileOutputStream fos = new FileOutputStream("C:\\sample.xlsx");
Sheet sh = wb.createSheet("newSheet1");
sh.createRow(0);

sh.getRow(0).createCell(0).setCellValue("Hours");
sh.getRow(0).createCell(1).setCellValue("Sunday");
sh.getRow(0).createCell(2).setCellValue("Monday");
sh.getRow(0).createCell(3).setCellValue("Tuesday");
sh.getRow(0).createCell(4).setCellValue("Wednesday");
sh.getRow(0).createCell(5).setCellValue("Thursday");
sh.getRow(0).createCell(6).setCellValue("Friday");
sh.getRow(0).createCell(7).setCellValue("Saturday");





for(int k = 1; k<25;k++){
sh.createRow(k);
sh.getRow(k).createCell(0).setCellValue(k-1);
}

for (int i = 0; i <>
for(int j = 0; j<24;j++){
sh.getRow(j+1).createCell(i+1).setCellValue("Row "+j+" Cell "+i);
}
}

To finish correctly you need add this:

wb.write(fos);
fos.close();




















Now, the file already contents the data.

See you.

Wednesday, 8 September 2010

How to install Eclipse SVN

How to install Eclipse SVN

SVN plugin is essencial for our Eclipse

To install it we need to do a few simple steps:

1.- Open Eclipse
2.- Press in the "Install New Software" in the Help tab.



3.- Press Add button: Eclipse will open a new window.
4.- In Name, we can put any name(Recommended a orientative words)
5.- In Location, we have to put this URL: http://subclipse.tigris.org/update_1.6.x



6.- Press OK button: the window will close
7.- In the background window will charge a 3 packages
8.- Mark the 3 packages (Core SVNKit Library, Optional JNA Library, Sublicpse)



9.- Press the next button
10.- Press the next button
11.- Mark the accept terms



12.- If any problem occur, we must accept the certificate(mark it) and press the next button




If you eant visit the official webPage... see this: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA

Regards

Monday, 6 September 2010

Error Tomcat " permission denied " calling webservice

Error tomcat permission denied calling webservice

This is a usual error when we work with webServices and Tomcat.
Read all Post before prove the solution.

The solution is:

Go to your Tomcat base directory
Find the file 50local.policy ( usually you can find it in "$TOMCAT_BASE/conf/policy.d/" ) If you haven't this directory structure, I'm sure that you can find the file catalina.policy in directory "$TOMCAT_BASE/conf/". (Both file are OK).

You have to edit one of these. At the final of the file you should type this:

//Grant all permissions to the Your Webservice Name
grant codeBase "file:${catalina.base}/webapps/yourWebserviceName/-" {
permission java.security.AllPermission;
};

Finally save the file and restart the server.

* You must replace the red text with your information.

I hope that this resolve your problem.
Regards.

Thursday, 2 September 2010

Error call AJAX JQuery


Error call AJAX with JQuery

I’m sure that you have ever had this problem.

" Access to restricted URI denied ” code: “ 1012 "

Or the AJAX request with JQuery is correct but it seems that don’t run?

Well, is very important to ensure that the call is being made to a service within the same domain as the AJAX service.

I always do the following: I create a web Service likes a Proxy. This will make the intermediary between the AJAX page and the world.

That is, our AJAX page always connect with our Proxy web Service, and this will implement the necessary calls to Internet.


Once done, our AJAX web and our Proxy web Service always will be together anywhere where we deploy them.

I personally, to create the Proxy web Service, use Java, creating a REST service with the Jersey library help. (this library is used to server and client). https://jersey.dev.java.net/

Later I will post a small tutorial on how to create a web Service REST in JAVA and how call to another web Service from JAVA.

Llamar AJAX xon JQuery: http://no-suelo.blogspot.com/2010/09/llamada-ajax-con-jquery-parametros.html


Regards.