How To Modify Data in A cell in Excel - qt
This is My Code and i am unable to set value/Modify value in a cell using
"QAxObject"...is there anyone help to get out from this issue
enter code here
QAxObject * range1 = range->querySubObject("Cells(int,int)",2,2);
range1->setPropertyWritable("Value",true);
range1->setProperty("Value","Serial");
qDebug()<<"propertyWritable === "
<< range1->property("Value");
Related
Python Selenium Webdriver Wait until Element is Loaded
The idea is to scrape a Website. By doing so, I wanted to scrape it via screenshots and then extract the data off the screenshot. Because in the Data I wanted to scrape is not in the HTML-Code and to be honest I didn't know how to handle it ( I am pretty new to python/programming). It is working fine so far, but I had the problem that WebDriverWait doesn't work properly. That's the Webpage: https://exporo.de/investment/betreutes-wohnen-huerth and in detail it's this dynamic part: <div class="key">Bereits investiert</div> <div class="value" ng-controller="pubSubController as pubSubCtrl" ng-show="pubSubCtrl.hasProject(2385)" ng-bind="pubSubCtrl.getProject(2385, 'total')"></div> So this is my code so far(the loop of it): while AktuellerWert1 < Endwert1: Zeit = datetime.now().strftime('%Y-%m-%d %H:%M:%S') driver1.get_screenshot_as_file(png_link % FileName1) img = Image.open(png_link % FileName1) PNG1 = image_to_string(img) PNG1_bearb = PNG1.split() AktuellerWert1 = PNG1_bearb[PNG1_bearb.index('investiert') + 1] Endwert1 = PNG1_bearb[PNG1_bearb.index('Finanzierungsziel') + 1] if AnfangsWert1 != AktuellerWert1: with open("/Users/davidoverbeck/Dropbox/Screen/Exporo/%s.csv" % FileName1, 'a') as csvFile: writer = csv.writer(csvFile) writer.writerow([AktuellerWert1, Zeit]) print(AktuellerWert1) else: pass AnfangsWert1 = AktuellerWert1 driver1.refresh() element = WebDriverWait(driver1, 2).until(EC.visibility_of_all_elements_located((By.XPATH, '/html/body/main/section[1]/section/div[2]/div[2]/div[1]/div[2]/div[10]/div[2]'))) else: with open("/Users/davidoverbeck/Dropbox/Screen/Abgeschlossen.csv", 'a') as csvFile: writer = csv.writer(csvFile) writer.writerow([Zeit, FileName1]) print(FileName1, 'abgeschlossen') driver1.close() It's working fine for 2 minutes and then it gives me the following error: selenium.common.exceptions.TimeoutException: Message: (no message behind it?!) I am not sure whether the loop does anything at all or, in case it's working, what's wrong with it? Thank you for your help!
I'm under the impression that the data you're looking for is here: https://exporo.de/pubsub/initial . In that case no need to parse html, you will need to parse the json. See F12 -> network tab -> Type column = json
Scilab - gui - many unknown variables error messages
Still trying to understand the logic of Scilab, I created a small calculation tool for a mechanical element. The main problem I have is finding the right order (or syntax) for the calculation code... I get a lot of "unknown variable" errors and I don't understand why? I tried to change the order of definitions for the functions, declare the variables as global, etc. but nothing seems to help. The code for the calculation is not long and also not complicated, but the gui was built using guibuilder, so the uicontrols definitions are probably much longer than they need to be. Could somebody help me make this code working, as I would learn and understand a lot by this example, althought it contains more than one "problem zones"? Here what I've done: G = 78500; table_titles = ["" "Wire diameter" "Wp" "Tau alwd" "M alwd" "Angle alwd"]; f=figure('figure_position',[910,163],'figure_size', [903,537],'auto_resize','on','background',[33],'figure_name','Graphic window number %d'); ////////// delmenu(f.figure_id,gettext('File')) delmenu(f.figure_id,gettext('?')) delmenu(f.figure_id,gettext('Tools')) toolbar(f.figure_id,'off') handles.dummy = 0; handles.sl_dwire=uicontrol(f,'unit','normalized','BackgroundColor', [-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma', 'FontSize',[12],'FontUnits','points','FontWeight','normal', 'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop', [],'Max',[12],'Min',[0],'Position', [0.0058208,0.77875,0.124375,0.06875],'Relief','default','SliderStep', [0.1,1],'Style','slider','String',"Wire diameter",'Value', [6],'VerticalAlignment','middle','Visible','on','Tag','sl_dwire', 'Callback','sl_dwire_callback(handles)') handles.ed_dwire=uicontrol(f,'unit','normalized','BackgroundColor', [-1,-1,-1],'Enable','off','FontAngle','normal','FontName','Tahoma', 'FontSize',[12],'FontUnits','points','FontWeight','normal', 'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop', [],'Max',[1],'Min',[0], 'Position',[0.0058208,0.71875,0.124375,0.06875],'Relief', 'default','SliderStep',[0.01,0.1],'String',"wire diameter: " + msprintf('%2.1f',handles.sl_dwire.Value) + "mm",'Style','text', 'Value',[0],'VerticalAlignment','middle','Visible','on','Tag', 'ed_dwire','Callback','auto') handles.sl_wangle=uicontrol(f,'unit','normalized','BackgroundColor', [-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma', 'FontSize',[12],'FontUnits','points','FontWeight','normal', 'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[180],'Min',[5],'Position', [0.0090625,0.5191667,0.25625,0.0645833],'Relief','default', 'SliderStep',[0.1,1],'String','Working angle','Style','slider','Value', [50],'VerticalAlignment','middle','Visible','on','Tag','sl_wangle', 'Callback','sl_wangle_callback(handles)') handles.ed_wangle=uicontrol(f,'unit','normalized','BackgroundColor', [-1,-1,-1],'Enable','off','FontAngle','normal','FontName','Tahoma', 'FontSize',[12],'FontUnits','points','FontWeight','normal', 'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1],'Min',[0],'Position', [0.0090625,0.4591667,0.25625,0.0645833],'Relief','default', 'SliderStep',[0.01,0.1],'String',"Working angle: " + msprintf('%2.1f',handles.sl_wangle.Value) + "°",'Style','text', 'Value',[0],'VerticalAlignment','middle','Visible','on','Tag', 'ed_wangle','Callback','auto') handles.sl_activel=uicontrol(f,'unit','normalized', 'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal', 'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight', 'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1000],'Min',[10],'Position', [0.0090625,0.365,0.25625,0.0645833],'Relief','default', 'SliderStep',[0.1,1],'String','Active length' ,'Style','slider', 'Value',[10],'VerticalAlignment','middle','Visible','on','Tag', 'sl_activel','Callback','sl_activel_callback(handles)') handles.ed_activel=uicontrol(f,'unit','normalized', 'BackgroundColor',[-1,-1,-1],'Enable','off','FontAngle','normal', 'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight', 'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1],'Min',[0],'Position', [0.0090625,0.305,0.25625,0.0645833],'Relief','default', 'SliderStep',[0.01,0.1],'String','Active length: ' + msprintf('%2.1f',handles.sl_activel.Value) + "mm",'Style','text','Value',[0],'VerticalAlignment','middle','Visible', 'on','Tag','ed_activel','Callback','auto') handles.ax_graph= newaxes();handles.ax_graph.margins = [ 0 0 0 0]; handles.ax_graph.axes_bounds = [0.4274266,0.0619266,0.3995485,0.5191743]; handles.tab_param=uicontrol(f,'unit','normalized','BackgroundColor', [-1,-1,-1],'Enable','on','FontAngle','normal','FontName', 'Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal', 'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1],'Min',[0], 'Position',[0.4308126,0.1690826,0.3950339,0.2178899],'Relief', 'default','SliderStep',[0.01,0.1],'String',string(table_param),'Style', 'table','Value',[0],'VerticalAlignment','middle','Visible', 'on','Tag','tab_param','Callback','tab_param_callback(handles)') handles.sl_sfactor=uicontrol(f,'unit','normalized', 'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal', 'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight', 'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1],'Min',[0], 'Position',[0.0058208,0.6525688,0.124375,0.06875],'Relief','default', 'SliderStep',[0.01,0.1],'String',"Safety factor",'Style', 'slider','Value',[0.58],'VerticalAlignment','middle','Visible','on', 'Tag','ed_sfactor','Callback','sl_sfactor_callback(handles)') handles.ed_sfactor=uicontrol(f,'unit','normalized', 'BackgroundColor',[-1,-1,-1],'Enable','off','FontAngle','normal', 'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight', 'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment', 'left','ListboxTop',[],'Max',[1],'Min',[0],'Position', [0.0058208,0.5925688,0.124375,0.06875],'Relief','default', 'SliderStep',[0.01,0.1],'String',"Safety factor : " + msprintf('%2.1f',handles.sl_sfactor.Value),'Style', 'text','Value',[0.58],'VerticalAlignment','middle','Visible','on', 'Tag','ed_dwire','Callback','auto') handles.popm_wtype=uicontrol(f,'unit','normalized', 'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal', 'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight', 'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left', 'ListboxTop',[],'Max',[1],'Min',[0],'Position', [0.0058208,0.8618349,0.124375,0.0639450],'Relief','default', 'SliderStep',[0.01,0.1],'String',gettext("SL/DL|SM/DM|SH/DH"),'Style', 'popupmenu','Value',[2],'VerticalAlignment','middle','Visible','on', 'Tag','popm_wtype','Callback','popm_wtype_callback(handles)') ////////// // Callbacks are defined as below. Please do not delete the comments as it will be used in coming version ////////// function sl_sfactor_callback(handles) sf=handles.sl_sfactor.Value; handles.ed_sfactor.String="Safety factor: " + msprintf('%3.2f',sf); endfunction function sl_dwire_callback(handles) wd=handles.sl_dwire.Value; Wp = %pi*wd^3/16; Ip =%pi*wd^4/32; Kt = G*%pi*Ip/(180*L); Talwd = sf * calcform; Malwd = Wp * Talwd; alphaalwd = Malwd / Kt; x=0:0.1:alphaalwd*1.5; plot(x,Kt*x); handles.ed_dwire.String="Wire diameter: " + msprintf('%2.1f',wd) + "mm"; endfunction function popm_wtype_callback(handles) //Write your callback for popm_wtype here if selected == 1 then calcform =(1845 - 700*log10(wd)); elseif selected == 2 then calcform =(2105 - 780*log10(wd)); elseif selected == 3 then calcform = (2220 - 820*log10(wd)); end endfunction function sl_wangle_callback(handles) handles.ed_wangle.String="Working angle: " + msprintf('%2.1f',handles.sl_wangle.Value) + "°"; endfunction function sl_activel_callback(handles) //Write your callback for sl_activel here handles.ed_activel.String="Active length: " + msprintf('%2.1f',handles.sl_activel.Value) + "mm"; L=handles.sl_activel.Value; endfunction function tab_param_callback(handles) //Write your callback for tab_param here table_values = string([ wd Wp Talwd Malwd alphaalwd]); table_param = [table_titles; [table_values]]; endfunction I expect the code to dynamically update the graph and the parameters table according to the positions of input sliders and popup-menu. Again, it would be very helpful if somebody could help me get this code working, as I would get answers for a lot of my questions concerning programming with scilab. Thank you very much in advance!
First of all, your code is not directly executable, caused by the linebreaks. Please add ... after each line of a statement. This improves also the readability. As mentioned by #luispauloml, you try to use variables, which exist just inside of another function. For example you try to reach table_param, which is just alive in tab_param_callback(handles). To get rid of this, you have to define the output for the function: function [table_values, table_param] = tab_param_callback(handles) table_values = string([ wd Wp Talwd Malwd alphaalwd]); table_param = [table_titles; [table_values]]; endfunction Now you can call this function to get the variable: string(tab_param_callback(handles)) I corrected just this case and added the dots as explained. For the other variables, it can be done analogously. Furthermore, I moved the function definition to the beginning of the code. Because if your scrips crashed in the middle, the compiler has no chance to read the function definitions. Please find the code in this file . I hope this helps. Good luck!
Get cell types when reading and parsing excel files
I am trying to read and parse and excel and some unclear things come into play as usual for me. Here is what i have: while (true) { comVariantCell1 = cells.item(row, 1).value().variantType(); comVariantCell2 = cells.item(row, 2).value().variantType(); //if an empty cell is found, processing will stop and user will get an error message in order to solve the inconsistency. if (comVariantCell1 != COMVariantType::VT_EMPTY && comVariantCell2 != COMVariantType::VT_EMPTY) { //both cells have values, check their types. importedLine = conNull(); progress1.setText(strfmt("Importing row %1", row)); if (cells.item(row, 1).value().variantType() == COMVariantType::VT_BSTR) { importedLine += cells.item(row, 1).value().bStr(); } else { importedLine += cells.item(row, 1).value().double(); } importedLine += cells.item(row, 2).value().double(); importedLinesCollection += [importedLine]; //conIns(importedLinesCollection, row - 1, (importedLine)); row++; } else { info (strFmt("Empty cell found at line %1 - import will not continue and no records were saved.", row)); break; } } Excel format: Item number Transfer Qty a100 50.5 a101 10 a102 25 This worked well to check if the cell type is string: COMVariantType::VT_BSTR but what should i use to check for a real or integer value ? I am pretty sure in this case, the quantity will be not contain real values but anyway, it could be useful in the future to make the difference between these two types. I have to mention that, even if i have an int value and I use cells.item(row, 1).value().int() it won't work. I can't see why. Why do i want to make the difference? Because if it's forbidden to have real values in the quantity column ( at least in my case ), i want to check that and give the user the opportunity to put a correct value in that place and maybe further investigate why that happened to be there.
Take a look on how it is done in \Classes\SysDataExcelCOM\readRow. It is basically using switch to test the type. This is really boring! Also take a look on ExcelIO, a class I made some years ago. It reads Excel and returns each row as a container. This is a more high-level approach. As a last resort you could save the Excel as a tab separated file. Then use TextIO to read the content. This will be at least 10 times faster than using Excel!
Getting an empty string when scanned
So I'm trying to create a Graph from a file input. The first line of the file contains an int and the second line in the file contains either a D or a U for directed and undirected. But when I did some troubleshooting to try and find the error in my code I found that my Scanner was scanning the second line as an empty string instead of the letter D. Here's my code. I rewrote the file so I know the file isn't wrong. The file is: 7 D (0, 1) (0, 3) . . . Code: public static Graph createFromFile(String filename) throws FileNotFoundException { File file = new File(filename); Scanner scan = new Scanner(file); int line1 = scan.nextInt(); vertexCount = line1; System.out.println(vertexCount); String line2 = scan.nextLine(); System.out.println(line2); String linne2 = "\"" + line2 + "\""; System.out.println(linne2); if(linne2.equalsIgnoreCase("D")){directed = true;} else if(linne2.equalsIgnoreCase("U")){directed = false;} else{System.out.println("This is not the proper input");} } The output is: 7 "" This is not the proper input Does anybody know where this issue is coming from?
scan.nextInt function doesn't take the execution to next line. So, scan.nextLine call is still on your first line and it returns rest of the data from first line , which in this case is basically space. Use one more scan.nextLine and it will give you expected result. Also , please go through the documentation of Scanner class , it will clear your doubts
Reformatting date in google spreadsheet
I'm setting up a spreadsheet for someone else with a form to enter data. One of the columns is supposed to hold a date. The input date format is like this example: "Jan 26, 2013" (there will be a lot of copy & paste involved to collect data, so changing the format at input step is not a real option). I need this date column to be sortable, but the spreadsheet doesn't recognize this as a date but simply as a string. (It would recognize "Jan-26-2013", I've tried.) So I need to reformat the input date. My question is: how can I do this? I have looked around and google apps script looks like the way to go (though I haven't found a good example of reformatting yet). Unfortunately my only programming experience is in Python, and of intermediate level. I could do this in Python without a problem, but I don't know any JavaScript. (My Python approach would be: splitted = date.split() newdate = "-".join([splitted[0], splitted[1][:-1], splitted[2]]) return newdate ) I also don't know how I'd go about linking the script to the spreadsheet - would I attach it to the cell, or the form, or where? And how? Any link to a helpful, understandable tutorial etc. on this point would help greatly. Any help greatly appreciated! Edit: Here's the code I ended up with: //Function to filter unwanted " chars from date entries function reformatDate() { var sheet = SpreadsheetApp.getActiveSheet(); var startrow = 2; var firstcolumn = 6; var columnspan = 1; var lastrow = sheet.getLastRow(); var dates = sheet.getRange(startrow, firstcolumn, lastrow, columnspan).getValues(); newdates = [] for(var i in dates){ var mydate = dates[i][0]; try { var newdate = mydate.replace(/"/g,''); } catch(err) { var newdate = mydate } newdates.push([newdate]); } sheet.getRange(startrow, firstcolumn, lastrow, columnspan).setValues(newdates) } For other confused google-script Newbies like me: attaching the script to the spreadsheet works by creating the script from within the spreadsheet (Tools => Script Editor). Just putting the function in there is enough, you don't seem to need a function call etc. you select the trigger of the script from the Script Editor (Resources => This Project's Triggers). Important: the script will only work if there's an empty row at the bottom of the sheet in question!
Just an idea : If you double click on your date string in the spreadsheet you will see that its real value that makes it a string instead of a date object is this 'Jan 26, 2013 with the ' in front of the string that I didn't add here...(The form does that to allow you to type what you want in the text area, including +322475... for example if it is a phone number, that's a known trick in spreadsheets cells) You could simply make a script that runs on form submit and that removes the ' in the cells, I guess the spreadsheet would do the rest... (I didn't test that so give it a try and consider this as a suggestion). To remove the ' you can simply use the .replace() method ** var newValue = value.replace(/'/g,''); here are some links to the relevant documentation : link1 link2 EDIT following your comment : It could be simpler since the replace doesn't generate an error if no match is found. So you could make it like this : function reformatDate() { var sheet = SpreadsheetApp.getActiveSheet(); var dates = sheet.getRange(2, 6, sheet.getLastRow(), 1).getValues(); newdates = [] for(var i in dates){ var mydate = dates[i][0]; var newdate = mydate.replace(/"/g,''); newdates.push([newdate]); } sheet.getRange(2, 6, sheet.getLastRow(), 1).setValues(newdates) } Also, you used the " in your code, presumably on purpose... my test showed ' instead. What made you make this choice ?
Solved it, I just had to change the comma to dot and it worked