Some time ago my brother backup phone address Book backup is the XLS table format, and now import not go in, with all kinds of software is wrong. I exported to the vcard (suffix is vcf), opened in text format looked under, found that the vcard is very formal specifications, suddenly feel a chance. You can try to convert an Excel table into a vcard format and then import it.
Begin:vcardn:; mobile customer service;;;;;; TEL; Cell:10086starred:falseuid:514version:3.0rev:20140602end:vcard
In a very obvious format, the second line is the name, and the Tel line is the number.
The format of the saved table is as follows:
Mobile |
10086 |
|
China Unicom |
|
10010 |
In this case, in fact, it is very simple, as long as the VCF format inside the name and number to fill a bit, and that UID I was directly to the number of loops.
General ideas have, and then to achieve.
1. Read xls, directly with the very old JXL package, now seems to have not been updated. And in the beginning with this operation of the table, prompted unable to recognize OLE stream, degrees Niang tell me, this is because:
What are you using 2007? JXL currently stop updating, can not read and write excel2007 if you want to read and write to use Apache POI, almost the use of Support 2003, 2007 online there are many instances.
No words, then directly with WPS Open XLS, Save as the old version of Xls,ok.
2,JXL's Grammar,
Refer to this article
JXL Manipulating table base syntax
3,buffer Writing Files
This section can be see a lot of things on the internet.
Jxl.jar Baidu Network disk Connection: Poke me to download
Just give the code,
Class Name: Oper.java
Package Core;import Java.io.bufferedwriter;import Java.io.file;import java.io.filewriter;import java.io.IOException ; Import JXL. Cell;import JXL. Sheet;import JXL. Workbook;import Jxl.read.biff.biffexception;public class Oper {void Test () {BufferedWriter Out;try {out = new BufferedWriter (New FileWriter ("Res/test.txt")), Out.write ("hello" + "\ r \ n" + "Hello"); Out.close (); catch (IOException e) {e.printstacktrace ();}} void work () {try {Workbook Book=workbook.getworkbook (new File ("Res/3.xls")); BufferedWriter out=new BufferedWriter (New FileWriter (New File ("RES/OUT.VCF"));//get the first sheetsheet sheet= Book.getsheet (0); for (int i=0;i<231;i++) {Cell Cell1=sheet.getcell (0,i); String name=cell1.getcontents (); Cell Cell2=sheet.getcell (1,i); String phone1=cell2.getcontents (); Cell Cell3=sheet.getcell (2,i); String phone2=cell3.getcontents (); String phone;if (Phone1.equals (")) Phone=phone2;else phone=phone1;out.write (" begin:vcard\r\n "+" N:; " +name+ ";;;;;; \ r\n "+" TEL; CELL: "+phone+" \r\nuid: "+i+" \ r \ n "+" VersiOn:3.0\r\nrev:20140602\r\nend:vcard\r\n "); Out.write (name);} Out.close (); Book.close ();} catch (Biffexception | IOException e) {System.out.println ("not find"); E.printstacktrace ();}} public static void Main (string[] args) {new Oper (). Work ();}}
I have been using WPS to view, there are 231 rows of data, so the loop 231 times.
The read-in file is/res/3.xls in the project directory, and the output is/RES/OUT.VCF. You can then import the catalog via various phone assistants.