Ребят помогите пожалуйста, есть файл excel , нужно прочитать из него ячейку (B2) , и потом текст из этой ячейски вставить в форму поиска.
Ребят помогите пожалуйста, есть файл excel , нужно прочитать из него ячейку (B2) , и потом текст из этой ячейски вставить в форму поиска.
Спасибо Дим большое) все получилось)
а на каком языке программирования надо было выполнить эту задачу?
ну раз решил, ты прикладывай код, чтобы другие также видели :)
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Iterator;import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;public class ReadXls {
<span style="color: rgb(128, 0, 0); font-weight: bold;">private</span> WebDriver driver<span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">private</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">String</span> baseUrl<span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">private</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">StringBuffer</span> verificationErrors <span style="color: rgb(128, 128, 48);">=</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">new</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">StringBuffer</span><span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">String</span> fileToBeRead <span style="color: rgb(128, 128, 48);">=</span> <span style="color: rgb(0, 0, 230);">"D://testdata2.xls"</span><span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(187, 121, 119);">void</span> main<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(187, 121, 119); font-weight: bold;">String</span> argv<span style="color: rgb(128, 128, 48);">[</span><span style="color: rgb(128, 128, 48);">]</span><span style="color: rgb(128, 128, 48);">)</span> <span style="color: rgb(128, 0, 128);">{</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">try</span> <span style="color: rgb(128, 0, 128);">{</span> HSSFWorkbook workbook <span style="color: rgb(128, 128, 48);">=</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">new</span> HSSFWorkbook<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(128, 0, 0); font-weight: bold;">new</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">FileInputStream</span><span style="color: rgb(128, 128, 48);">(</span> fileToBeRead<span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> HSSFSheet sheet <span style="color: rgb(128, 128, 48);">=</span> workbook<span style="color: rgb(128, 128, 48);">.</span>getSheet<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(0, 0, 230);">"Zakladka2"</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> HSSFRow row <span style="color: rgb(128, 128, 48);">=</span> sheet<span style="color: rgb(128, 128, 48);">.</span>getRow<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> HSSFCell cell <span style="color: rgb(128, 128, 48);">=</span> row<span style="color: rgb(128, 128, 48);">.</span>getCell<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(187, 121, 119);">short</span><span style="color: rgb(128, 128, 48);">)</span> <span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">System</span><span style="color: rgb(128, 128, 48);">.</span>out<span style="color: rgb(128, 128, 48);">.</span>println<span style="color: rgb(128, 128, 48);">(</span>cell<span style="color: rgb(128, 128, 48);">.</span>getRichStringCellValue<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 128);">}</span> <span style="color: rgb(128, 0, 0); font-weight: bold;">catch</span> <span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(187, 121, 119); font-weight: bold;">Exception</span> e<span style="color: rgb(128, 128, 48);">)</span> <span style="color: rgb(128, 0, 128);">{</span> <span style="color: rgb(187, 121, 119); font-weight: bold;">System</span><span style="color: rgb(128, 128, 48);">.</span>out<span style="color: rgb(128, 128, 48);">.</span>println<span style="color: rgb(128, 128, 48);">(</span><span style="color: rgb(0, 0, 230);">"!! ERORR!!!!!!!!!! "</span> <span style="color: rgb(128, 128, 48);">+</span> e<span style="color: rgb(128, 128, 48);">)</span><span style="color: rgb(128, 0, 128);">;</span> <span style="color: rgb(128, 0, 128);">}</span> <span style="color: rgb(128, 0, 128);">}</span>
}
Пишу на Java , стаж 3 месяца, что-то дается не сразу, поэтому с опытым приходится переписывать.
если код где-то не корректный поправьте пожалуйста.
больше практики и опыт придет
всему свое время :)
еще можна google doc api юзать, когда xls файли например в гугл доках храняться