Home > Back-end >  How to implement Java excel text respectively?
How to implement Java excel text respectively?

Time:09-15

Select the whole column, "data" - & gt;" Respectively - & gt; "" Separator "- & gt;" The next step - & gt; "" The TAB key - & gt; "" The next step - & gt; "" Conventional - & gt; "" Complete "

https://www.cnblogs.com/Devin-Blog/p/6253143.html

I need to implement scenario is: I use easyexcel will have custom data imported into the format of the column, the custom format does not automatically take effect, can't do without manual operation, such as double click or just like the above operation need code now, easyexcel encapsulates the poi

The above operation, how to use code implementation, also please bosses some directions

CodePudding user response:

Easyexcel is not very familiar with, free spire. XLS for Java class library can achieve excel text respectively, the following is the implementation code, for your reference
 import com. Spire. XLS. ExcelVersion; 
The import com. Spire. XLS. Workbook;
The import com. Spire. XLS. Worksheet;

Public class ConvertTextToColumns {
Public static void main (String [] args) {
//create Workbook instance
Workbook Workbook=new Workbook ();
//load the Excel document
Workbook. LoadFromFile (" Template. XLSX ");

//get the first worksheet
Worksheet sheet=workbook. GetWorksheets (). The get (0);

String [] splitText=null;
String text=null;
//will work the text in the first column in the table according to the separator (here is a space) for split columns
For (int I=1; i {
Text=sheet. GetRange (). The get (I, 1). The getText ();
SplitText=text. The split (" ");
For (int j=0; J & lt; SplitText. Length; J++)
{
Sheet. GetRange (). The get (I, 1 + j + 1) setText (splitText [j]);
}
}

//save the document
Workbook. SaveToFile (" ConvertTextToColumns. XLSX, "ExcelVersion. Version2013);
}
}

CodePudding user response:

No, I tried this,,,
  • Related