public class Tab1 extends Fragment implements OnClickListener {
TextView text_fname, text_lname;
EditText edit_fname, edit_lname;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.tab1, container, false);
text_fname = (TextView) v.findViewById(R.id.text1);
text_lname = (TextView) v.findViewById(R.id.text2);
edit_fname = (EditText) v.findViewById(R.id.edit1);
edit_lname = (EditText) v.findViewById(R.id.edit2);
Button button = (Button) v.findViewById(R.id.button1);
button.setOnClickListener(this);
return v;
}
@Override
public void onClick(View arg0) {
String fname1 = text_fname.getText().toString();
String fname2 = edit_fname.getText().toString();
String lname1 = text_lname.getText().toString();
String lname2 = edit_lname.getText().toString();
String space = " ";
String newLine = "\n";
File file = null;
FileOutputStream fos = null;
try {
file = getActivity().getFilesDir();
fos = getActivity().openFileOutput("test.xls", Context.MODE_PRIVATE);
fos.write(fname1.getBytes());
fos.write(space.getBytes());
fos.write(fname2.getBytes());
fos.write(newLine.getBytes());
fos.write(lname1.getBytes());
fos.write(space.getBytes());
fos.write(lname2.getBytes());
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (fos!=null) {
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Toast.makeText(getActivity(), "File saved in " + file, Toast.LENGTH_LONG).show();
}
}
Как я могу поместить fname2 и lname2 в следующую ячейку, когда я открою ее в excel? Я попробовал добавить "", но это только добавляет пробел. Вот выходной ток:Поместите строку в другую ячейку в excel
То, что я хочу есть, «микки» и «мышь», чтобы быть на колонке B
я не пробовал \ S, но \ т работал. – luwionline