SXSSF doesn't support Rich Text Strings, any formatting information will be lost - sxssf

#When i use SXSSF to write a file,it happend,but i don`t know why.Here is my code:#
SXSSFWorkbook workbook = new SXSSFWorkbook()
SXSSFSheet currentSheet = workbook.createSheet()
SXSSFRow row = sheet.createRow(0);
SXSSFCell cell = row.createCell(0);
cell.setCellValue( obj);
##Now,the log will show "SXSSF doesn't support Rich Text Strings, any formatting information will be lost".##

This log will keep printing, I don't know the exact fix for it but I found work around solution to avoid unnecessary logging.
Step 1: Create your own rich text method
protected XSSFRichTextString richTextString(Object object) {
return new XSSFRichTextString((String) object);
}
Step 2: While assigning value to cell call the above method pass whatever object to it.
protected void addCell(Workbook workbook, Row row, Integer i, Object
object) {
Cell cell = row.createCell(i);
cell.setCellValue(richTextString(object));
}

Related

iOS : How to get value in FXForms

How can I get actual value of field which user is selected in field,
In this method I got only number of index which user selected, but I need the value (string) of that.
(void)submitRegistrationForm:(UITableViewCell *)cell
{
//we can lookup the form from the cell if we want, like this:
RegistrationForm *form = cell.field.form;
NSLog(#"Country : %d",form.selectYourCountry);
// How to get country name over here.
}
Thanks,
I had the same issue, got confused about how to get the values in the FXForms, then after reading the comments in the DynamicForm class, posting the solution for anyone else who faces the issue in future
-(void)submitRegistrationForm:(id)sender
{
NSLog(#"Form Submitted");
DynamicForm *form=self.formController.form;
NSDictionary *values=form.valuesByKey;
NSLog(#"values:- %#",values);
}
ps: my self is a subclass of FXFormViewController

PreferenceBundle: "number in code"

I'm searching some help for an item in the PreferenceBundle.
For example, I have this simple code:
-(int)XXX {
return 100;
}
How can I put in the PreferenceBundle a cell where you can write the number to return the function?
For example:
1) You write 5 and the function will be:
-(int)XXX {
return 5;
}
2) you write 24:
-(int)XXX {
return 24;
}
Thanks all
Using a PSEditTextCell and the data found in the wiki page you can add this specifier to your preferences pane. You can use NSUserDefaults and the notification posted from the cell being edited (you have to specify that) to retrieve the value the user has set and return it in your method.
You can use the code here to see how to setup and read the user preferences for your tweak.

How do I get value of cell before it changes in Google spreadsheet?

This function seems not to be triggered until the cell is exited, as the value i'm getting is the post-change value. I need the pre-change value, but I only need it if in fact that particular column is edited.
Thank you
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
var columnNum = r.getColumn();
var msg;
if (columnNum == 11) {
var dateCell = s.getRange(r.getRow(), 11);
var v=dateCell.getValue();
msg = 'Value= ' + v;
Browser.msgBox (msg);
//dateCell.setValue(v);
}
}
This is a very old question, but in case anyone else needs the answer, it's quite easy to get both the old and new values of any edited cell with the event object:
function onEdit(e) {
let oldValue = e.oldValue;
let newValue = e.value;
console.log("The range's old value was: " + oldValue + ", and the updated value is: " + newValue);
}
Here are are the accessible properties of the Google Sheets event objects.
To the best of my knowledge, capturing the value of a cell before an edit is still not possible.
You might like to star this issue on the issue tracker; it is currently deemed a medium-priority enhancement request.
#AdamL Is there anyway to access the spreadsheets revision history programmatically?
Sorry this is beyond my noob abilities, but my question may hold the clue to a workaround for A B's issue.
#A B ANOTHER POSSIBLE WORKAROUND
You could set up a time based triggers to populate 2 arrays. 1 array from the current data in the column your checking for edits, and 1 array from a previous snapshot of the same data. Then by using a loop to test if any values have changed since your last trigger event, you can determine what value/values have changed(if any) If a value your testing for has changed then push the rowNumber() and colNumber() and getValue() of both previous and current instances of the same data to a new array, also include a timestamp new Date(). Have this new array data populate a new sheet or spreadsheet.
If used in conjunction with your onEdit function, yourll be able to see the before and after value changes, and the approximate time they occured.
Time based triggers can be set to run every minute, hour day etc

Javafx-2 tableview bindings with none text cells

I would like to show a series of financial transactions in a TableView.
Each Transaction consists of a Date, a Description and an Amount.
I can make this work using bindings if I treat all the cells as Text using the example shown in a reply to another question. This allows in cell editing which is my goal.
But I can't get it to work on the date and amount columns, I think I need a separate cell factory for each cell type and a possibly a separate updateItem method but I'm stuck.
Any pointers to an example or suggestions would be helpful.
You may want to check out the DataFX project at:
http://www.javafxdata.org/
and specifically the cell factories like:
http://www.javafxdata.org/javadoc/org/javafxdata/control/cell/TextFieldCellFactory.html
DataFX contains custom cell factories for several data types, tables, lists and tree views. Assuming that for example your amount has a double type, you could write something similar like that in a subclass of TableColum
(replace ??? by the class name of the class that represents a row in your table):
setCellFactory(TextFieldCellFactory.<???, Number>forTableColumn(new Callback<String,Number>(){
#Override
public Number call(String newValueStr) {
double newValue = Double.parseDouble(newValueStr);
return newValue;
}));
setOnEditCommit(new EventHandler<CellEditEvent<???, Number>>() {
#Override
public void handle(CellEditEvent<???, Number> t) {
double newValue = t.getNewValue().doubleValue();
// do something with the double value the user entered here
}
});
}
}
I hope that at least gives you some direction. I have left out Exception handling for clarity.

Indexed TableViews not displaying after upgrade to MT 4.0

After upgrading to MT 4.0, my TableViews that previously were displaying indexes on the right hand border are no longer working. The tableview still displays in sections and works properly, but the index is not displaying.
I have these three methods defined in my UITableViewSource, and all three appear to be working:
public override string[] SectionIndexTitles(UITableView tableView)
public override int SectionFor(UITableView tableView, string Title, int atIndex)
public override string TitleForHeader(UITableView tableView, int section)
Is anyone else having this problem? Is this a bug with MT 4.0?
This is a known bug.
It appears that UITableView is not retaining the returned array, you can use
the following to work around this issue while we investigate it further:
NSArray array;
[Export ("sectionIndexTitlesForTableView:")]
public NSArray SectionTitles (UITableView tableview)
{
if (array == null) {
string[] titles = new string[RowsInSection(tableview, 0)];
for (int index = 0; index < titles.Length; index++)
titles[index] = index.ToString();
array = NSArray.FromStrings (titles);
}
return array;
}
This was showing to me just numbers (index for each item of the section 0 (like A letter of the index), so I found that must change this to:
NSArray array;
[Export ("sectionIndexTitlesForTableView:")]
public NSArray SectionTitles (UITableView tableview)
{
if (array == null)
{
array = NSArray.FromStrings (SectionIndexTitles(tableview));
}
return array;
}
To all people who don't get the workaround to work correctly:
For me it was because I left the MonoTouch override method SectionIndexTitles in there - as soon as I removed it (or in my case renamed it so it can be called from the workaround), it worked as described :)
Getting the same problem, but the above fix did not work, I am sure it is probably something simple that I am doing wrong. The below methods are part of a UITableViewSource. All working as it was before MT 4.0, however the textual Index is not appearing. Debug output listed below the code shows that SectionTitles is not being called. Any thoughts on how this differs from the solution above, and how to get it working? Happy to start a new thread on this, but thought that it might be useful to have more information on this question instead.
NSArray array;
[Export ("sectionIndexTitlesForTableView:")]
public NSArray SectionTitles(UITableView tableview)
{
Debug.WriteLine("SectionTitles");
if (array == null)
{
array = NSArray.FromStrings(SectionIndexTitles(tableview));
}
return array;
}
public override string[] SectionIndexTitles(UITableView tableView)
{
Debug.WriteLine("SectionIndexTitles");
var sectionIndexTitles = Root.Sections.Select(section => section.IndexTitle ?? string.Empty);
var applySectionIndexTitles = sectionIndexTitles.Any (sectionIndexTitle => !string.IsNullOrEmpty (sectionIndexTitle));
foreach (string s in sectionIndexTitles)
{
Debug.WriteLine(s);
}
Debug.WriteLine("applySectionIndexTitles = " + applySectionIndexTitles);
return applySectionIndexTitles ? sectionIndexTitles.ToArray () : null;
}
Debug output:
SectionIndexTitles
A
B
C
D
E
F
G
H
J
K
L
M
N
O
P
R
S
T
W
applySectionIndexTitles = True
Wow, the answers here are a extremely misleading. Where do I start?
First, why are the examples using a backing NSArray? Why not a string [] for the backing data? Just because the method returns a NSArray doesn't mean you have to back it with an NSArray. Yikes. Why would you use an NSArray unless you have to. You don't have to here.
Second, realistically, I always store my index titles in a backing string []. That is normal use I'd say. Why wouldn't you do that anyway? The answers here make it sounds like it's a special case or something where you have to store it. As far as I know you are always responsible for doing that anyway. And another example relying on the cells to get data... Why on earth? If you can't simply use an array then get a clue that your array is out of scope or something.
Also, some people mentioned to not override as you normally would. Ummm... I don't know about that. That completely contradicts all the monotouch code I've seen. I've seen a lot of examples do both and it makes sense. Look at some of the template UIViewController constructors. The internal calls that explicitly reference selectors will need the selector. Normally you wouldn't need one but in this case apparently something internal is broken referencing the selector. That is NOT a reason to ditch overriding it as you normally would. You still need to override it in case you have some external call that came from your own managed code. You should absolutely still override it. Unless you always explicitly referencing selectors in YOUR code... then keep it overriden.
Anyway, a lot of this is my general monotouch understanding and I could be wrong. I mean, I don't know... I'm seriously not trying to criticize. I just had to comment because it looks like to me there is A LOT of bad information in this thread and I'm hoping this post will help someone who might be getting misinformed.

Resources