Sunday, 15 January 2012

apache poi cellIterator skips blank cells but not in first row -



apache poi cellIterator skips blank cells but not in first row -

i creating java programme read excel sheet , create comma separated file. when run sample excel file, blank columns, first row works perfectly, rest of rows skip blank cells. have read code changes required insert blank cells rows, question why first row work ????

public arraylist openandreadexcel(){ fileinputstream file = null; hssfworkbook workbook = null; arraylist <string> rows = new arraylist(); //open file seek { file = new fileinputstream(new file("fruity.xls")); } grab (filenotfoundexception e) { // todo auto-generated grab block system.out.println("could not open input file"); e.printstacktrace(); } // open input stream workbook seek { workbook = new hssfworkbook(file); } grab (ioexception e) { // todo auto-generated grab block system.out.println("can't open hssf workbook"); e.printstacktrace(); } // sheet hssfsheet sheet = workbook.getsheetat(0); // add together iterator every row , column iterator<row> rowiter = sheet.rowiterator(); while (rowiter.hasnext()) { string rowholder = ""; hssfrow row = (hssfrow) rowiter.next(); iterator<cell> celliter = row.celliterator(); boolean first =true; while ( celliter.hasnext()) { if (!first) rowholder = rowholder + ","; hssfcell cell = (hssfcell) celliter.next(); rowholder = rowholder + cell.tostring() ; first = false; } rows.add(rowholder); } homecoming rows; } public void writeoutput(arraylist<string> rows) { // todo auto-generated method stub printstream outfile ; seek { outfile = new printstream("fruity.txt"); for(string row : rows) { outfile.println(row); } outfile.close(); } grab (filenotfoundexception e) { // todo auto-generated grab block e.printstacktrace(); } }

} ----- input in .xls file (sorry don't know how insert excel table here ) name >>>>>>>>>> country of origin >>>>>>>>> state of origin >>>>>>> grade>>>>>> no of months apple >>>>>>>> usa >>>>>>>>>>>>>>>>>>>>>> washington >>>>>>>>>>>>>> >>>>>>>>> 6 orange >>>>>> usa >>>>>>>>>>>>>>>>>>>>>> florida >>>>>>>>>>>>>>>>> >>>>>>>>> 9 pineapple>>>>> usa >>>>>>>>>>>>>>>>>>>>>> hawaii >>>>>>>>>>>>>>>>>> b >>>>>>>>> 10 strawberry>>>> usa >>>>>>>>>>>>>>>>>>>>>> new jersey>>>>>>>>>>>>>> c >>>>>>>>>> 3 my output text file name ,country of origin,state of origin,,,grade,no of months apple,usa,washington,a,6.0 orange,usa,florida,a,9.0 pineapple,usa,hawaii,b,10.0 strawberry,usa,new jersey,c,3.0

notice 2 commas before grade column... because have 2 blank columns there.<br/>

these commas missing in rest of output.

i using apache poi-3.9-20121203.jar

you should have read through iterating on rows , cells documentation on apache poi website.

the celliterator homecoming cells have been defined in file, largely means ones either values or formatting. excel file format sparse, , doesn't bother storing cells have neither values nor formatting.

for case, must have formatting applied first row, causes them show up.

you need read through documentation , switch lookups index. allow total command on how blank vs never used cells handled in code.

apache-poi

php - CDbCriteria condition from another CDbCriteria -



php - CDbCriteria condition from another CDbCriteria -

i don't if want possible or not, have 2 models want info 1 model using status another.

$criteria1=new cdbcriteria; $paramids = $s['param_id']; $stress = model1::model()->find($criteria1); $mycondition= ($stress->stress_value); echo $mycondition ; // value , want utilize // status next cdbcreteria $criteria2=new cdbcriteria; // status $criteria2->addcondition(array('pressure_value' > $mycondition)); // can't perform status $criteria2->order = "pressure_value desc"; $pressure = model2::model()->find($criteria2);

any thought ? code wrong or want not possible in way ?

many thanks

thanks @Örs

your solution work me making compare statement in cdbcreteria after condition

$criteria2->params = array(':value' => $mycondition)

php yii

Not Getting External Font in Android -



Not Getting External Font in Android -

i not getting external font, creating new class, defined external font.

fontstyle.java

public class fontstyle extends activity{ public final static string roboto_regular = "fonts/roboto_regular.ttf"; public typeface font_roboto_regular = typeface.createfromasset(getassets(), roboto_regular); }

and mainactivity.java

public class mainactivity extends activity { fontstyle font_style; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); fontstyling(); } private void fontstyling() { textview test= (textview) findviewbyid(r.id.tv_test); test.settypeface(font_style.font_roboto_regular ); }

i getting error or logcat:

java.lang.runtimeexception: unable start activity componentinfo{com.test/com.test.mainactivity}: java.lang.nullpointerexception

please guy right me: in advance.

first need pass activity context in fontstyle access getassets method. if fontstyle not activity no need extends activity it. alter fontstyle class as:

public class fontstyle { context context; public final static string roboto_regular = "fonts/roboto_regular.ttf"; public fontstyle(context context){ this.context=context; } public typeface getttypeface(){ typeface font_roboto_regular = typeface.createfromasset(context.getassets(),roboto_regular); homecoming font_roboto_regular; } }

now alter activity code set custom font textview :

public class mainactivity extends activity { fontstyle font_style; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); font_style=new fontstyle(mainactivity.this); fontstyling(); } private void fontstyling() { textview test= (textview) findviewbyid(r.id.tv_test); test.settypeface(font_style.getttypeface()); }

android fonts

Uploading image to a submit form via PHP and curl -



Uploading image to a submit form via PHP and curl -

i have upload set of images submit form in page. think can done php , curl. when checked submit form action file, noticed using post request payloads upload images.

can help me in telling how add together payload post request. need basic knowledge along sample code how images uploaded server etc. tried number of codes here , there on so, none of them worked out case. so, thought going through basics more of import ! able write case.

updates :-

i have come solution

function curl_post_request($url, $data, $referer='') { $data = http_build_query($data); $c = curl_init(); curl_setopt($c, curlopt_url, $url); curl_setopt($c, curlopt_returntransfer, true); curl_setopt($c, curlopt_header, true); curl_setopt($c, curlopt_post, true); curl_setopt($c, curlopt_postfields, $data); curl_setopt($c, curlopt_referer, $referer); curl_setopt($c, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.1) gecko/20061204 firefox/2.0.0.1"); curl_setopt($c, curlopt_header, $headers); curl_setopt($c, curlinfo_header_out, true); curl_setopt($c, curlopt_verbose, true); $output = curl_exec($c); var_dump(curl_getinfo($c, curlinfo_header_out)); if($output === false) trigger_error('erreur curl : '.curl_error($c),e_user_warning); curl_close($c); homecoming $output; } if(isset($_get['go'])) { $data = array( 'file_0' => "@".realpath('rupee.png'), 'file_1' => "@".realpath('sel.jpg') ); $url = 'http://demo.ipol.im/demo/my_affine_sift/input_upload'; print_r($data); $a = curl_post_request($url, $data); var_dump($a); } else { print_r($_post); print_r($_files); }

output of code can seen here

issue being, files uploading should have attribute filename. also, unable add together attribute it. tried changing $data array using. solution ?

further update :-

added filename attribute , still the receiving end not able filename :(

$data = array( 'file_0' => '@'.realpath("rupee.png").';filename='.$filename1, 'file_1' => '@'.realpath("sel.jpg").';filename='.$filename2 );

thanks !

php curl image-uploading

javascript - jQuery is unexpectedly executed in new tab once element is clicked -



javascript - jQuery is unexpectedly executed in new tab once element is clicked -

i tried have navigation slide in on-screen in viewport after beingness off-canvas via jquery when css3 transitions not supported.

however, happening ( 1 time jquery event occurs ) new tab opened contains same page jquery executed.

in other words, when list-icon clicked new tab opened , navigation slides in in new tab. want slide in in current window / tab.

i appreciate , help in achieving this.

here running live example: http://db.tt/gykxa5nf

javascript jquery modernizr

iphone - Constraints issue in Xcode -



iphone - Constraints issue in Xcode -

i'm having issues constraints in app. here how looks on iphone 4 (that's how want look, , how setup interface, proper approach or not?)

now, when switch iphone 5 screen looks

and can see, bluish dots (which uibuttons) not placed want them be. made constraints rely solely on right side of view (since 1 re-sizing, found in order you'r views align accordingly, doesn't help align them left side). don't know how prepare this. finding new iphone screen real pain in arse. advice on how work new screen without lot of headache appreciated :)

thanks on advance

it looks me still same distance right side of view, said set them be, while background has stretched fit new size. suspect it's background isn't doing want (keep same aspect ratio , show more stuff on left), or seek keeping buttons relating left , right remain aligned stretched background image.

iphone ios objective-c xcode constraints

vb.net - DataTable Column.Expression Throw Error -



vb.net - DataTable Column.Expression Throw Error -

i have info table contains few row below

ch1 ch2 ch3 ch4 ch5 1 2 1 2 3 3 3 1 2 3 3 3 1 1 2 1 3 3 3 3 1 2 3 3 0 3 3 1 2 0 3 3 1 1 2

then seek add together new column like

dim col new datacolumn("vch1", gettype(decimal),"(ch1+ch2+ch3)/ch5") dtreadings.columns.add(col)

at time give me error : attempted split zero. because of ch5 have 0 values, need add together dynamic column different look @ run time ,how avoid such type of error thought please help.

expression value not fixed,user create look dynamic column. not handle split 0 error ,to handle type of computing error

the expression syntax allow utilize of iif statement build datacolumn using kind of syntax expression

col = new datacolumn("vch1", gettype(decimal), "iif(ch5 = 0, 0, (ch1+ch2+ch3)/ch5)")

of course, beingness look string property build look dynamically based on particular requirement have @ moment. iif or isnull build string on fly before adding column. pseudocode

dim currentexpression string = buildcurrentexpression() col = new datacolumn("vch1", gettype(decimal), currentexpression)

vb.net winforms datatable