Forgot your password?
Sign in with
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View C++ questions
View Java questions
All Message Boards...
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Design and Architecture
Internet of Things
C / C++ / MFC
ATL / WTL / STL
Objective-C and Swift
Hardware & Devices
Hosting and Servers
.NET (Core and Framework)
Site Bugs / Suggestions
Spam and Abuse Watch
The Insider Newsletter
The Daily Build Newsletter
Most Valuable Professionals
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
What is 'CodeProject'?
Ask a Question
Bugs and Suggestions
Article Help Forum
Comments by matblue25 (Top 27 by date)
Thanks but that seems like cheating. :) I did do some searching in the MS documentation. Deleting a sheet is supposed to pop up a confirmation dialog box. The Delete() method returns a boolean True or False depending on whether the user confirmed the delete or not. In one example snippet, somebody added this: xlApp.DisplayAlerts = false; worksheet.Delete(); xlApp.DisplayAlerts = true; to disable the popup. None of that explains why it would work in one place in your code and not another unless maybe you have DisplayAlerts turned off in the part of the code where it works.
No error messages or anything? Yeah, seems like it should either work or error?
You need to think about what you're trying to accomplish. There are two things you need to make the chart. X-axis values, in radians, from 0 to 2*pi, with the number of samples equal to samplerate/freq. Then the Y-axis values being the sine of the x-axis value. So, the only difficulty is determining what all the X-axis values are, evenly spaced from 0 to 2*pi divided by the number of samples. It looks like you're only trying to plot one "wave" of the sine curve, no matter what the frequency. Note that, in your C# code, you're using the Math.Sin function for both the X and Y values (in your case, Y is "t"). You might be confused because the Matlab code has them reversed. What it calls "x" is the sine value (plotted on the Y-axis) and its "t" is the X-axis, in seconds.
Run it in debug and check the value of destinationWorkbook.Worksheets(1) inside CopyTotalsSheet(). You may need to set it in that method. From the code you supplied, I can’t tell where destinationWorkbook is declared and whether it’s still pointing to the open destination file in the CopyTotalsSheet method.
Why square brackets instead of parentheses? Worksheets["Totals"]
The first time through your “for(int i = 0;” loop, the attempt to set “excelWorksheet.Cells[1, i].Value” will fail because Excel rows and columns start at 1.
Ok, you're iterating every cell from the used range of one sheet and, if it doesn't contain a formula, looking at the same cell in a different workbook but with the same worksheet name and, if the cell in the 2nd sheet doesn't contain a formula, set it to the value of the cell from the 1st sheet. What part of this either doesn't work or do you want to change? I don't understand the "for (int i = 1; i <= 6; i++)" loop. It looks like nothing happens except for the 3rd time thru the loop ("if (sheet1.Equals(sheet2) && i == 3)". What's the point of that? I don't see anywhere else the where the index "i" is used.
If you want to post the excel file, I can look at it. Don't do it if it contains any sensitive information. I've tried but I can't duplicate the problem if there's a chart on the sheet.
Did you ever figure this out?
Sorry I couldn't be more help.
I think I'd just copy the worksheet from one workbook to the other. If you want to remove the formulas, select all the cells in the worksheet, copy them and then pastespecial "values".
Something weird is going on. Try changing "ChartObjects" to "Shapes". The Shapes collection is any object like a drawing or picture or chart. See if you can find your chart by iterating through the Shapes. If you find it as a Shape but not as a ChartObject, that's a clue. Look at each shape's "type" property to see what type of shape it is. The enum values for types is documented at:
Put in a debug statement chartcount = totalWorksheet.ChartObjects.count to see if there are, in fact, charts in the sheet you should be able get the first one using ChartObjects(1) if there is
I don’t know if this will help or not but the “.xls” extension corresponds to the xlWorkbookNormal format. xlWorkbookDefault is the “.xlsx” file format.
Dates in Excel are stored as numbers with the value 1.0 being January 1, 1900 12:00:00am. You're going to have to convert the Excel value using the xlrd method xlrd.xldate.xldate_as_datetime(xldate, datemode). You get the "datemode" value from the workbook (it can refer to different starting dates). The error message says its getting the value 44579, which is January 18, 2022 in Excel, so it is getting the right cell. This may help too:
XLRD Note on Excel Dates
In particular note that it says: "When using this package’s xldate_as_tuple() function to convert numbers from a workbook, you must use the datemode attribute of the Book object. If you guess, or make a judgement depending on where you believe the workbook was created, you run the risk of being 1462 days out of kilter."
I don't think I can help with that. I'd recommend you step through the code in the debugger and look at the value of "header" when the error occurs and compare that to what the documentation of the "createElement" method requires in org.w3c.dom.Document. I looked at the method and it says the INVALID_CHARACTER_ERR is raised if the specified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute. So something is wrong with the value of "header". According to W3C: XML elements must follow these naming rules: Element names are case-sensitive. Element names must start with a letter or underscore. Element names cannot start with the letters xml (or XML, or Xml, etc) Element names can contain letters, digits, hyphens, underscores, and periods. Element names cannot contain spaces. Seems pretty simple. You must be violating one of these requirements.
Have you stepped through it in the debugger to make sure the dgvCompany data is loaded the 1st time it's called?
You're setting the string variable "XML" to Null then calling your convertFile method passing it as the 2nd argument. The first time you use the 2nd argument in the convertFile method is: writer = new FileWriter(new File(xmlFileName)); So, you're trying to create a new File with a null string. That's not going to work. You didn't take my hint in my earlier message. Just try setting XML = "outputfile.xml"; in the initialize method.
You have to look at and understand all of the code in the convertFile method. The arguments for convertFile are: String csvFileName, String xmlFileName and char delimiter. Look at how those variables get used in the method. The only use of csvFileName is to create csvReader as a BufferedReader object. All it does is read the file. Don't be "afraid" of the code - understand it. In any case, if you're worried that the file might get destroyed or changed, save a copy of it somewhere else and work with the copy. That's not unusual. If you're developing and testing some code that will permanently change some thing, you're better off working with copies of the thing as you're testing your code, at least until you're sure it's working correctly. As far as how the convertFile method uses the string xmlFileName, I'm going to let you do the work rather than just tell you but LOOK AT THE CODE! The variable is declared as a string for a reason! Look at what convertFile does with that string. Hint: you're going to want to set xml to something like "outputfile.xml". If you pass objects other than what a method expects, you're going to get all kinds of strange error messages because it will not know what to do with them. When calling a method, you have to give the method EXACTLY what it's looking for - not what you think it ought to use. Look at the code in the method to see what it uses the arguments for. Don't assume. Learn to use the debugger and step through the code one line at a time and look at the values of the variables as you go along. You can't be an accomplished software developer without being an expert at debugging. It's like trying to be a carpenter without knowing how to use a saw.
A mathematician would say no. Anything divided by zero is undefined. If you divide a number by progressively smaller and smaller numbers, the result approaches infinity but that doesn't mean that dividing by zero equals infinity.
Wikipedia - Divide by zero
EDIT: Also look at this thread - I didn't realize it but this is a well-known behaviour in C# .NET
CodeProject Thread on Divide by Zero
There are a lot of unknowns here. What do the five programs do? Please describe. How do you want them to work when invoked from the form? You say you want "main menu tool strip" to "load" the programs. What does Form2 look like? You say it's a "blank form2" but it's a form that you created? We don't know what it looks like or what controls you have put in the form. Have you created a menu bar (menu strip) in it? If you have, you need to "load" the programs from the Click events of the menu strip items.
Are these embedded OLEObjects or are they hyperlinks to files stored elsewhere? An OLEObject can't be considered as "in" a particular cell since they are like embedded images, they can be moved and resized to overlap multiple cells. The have a "TopLeftCell" property (as an Excel object) that is the cell where that top left corner of the object lies in. But it's not part of that cell, per se. You might want to look at:
The message is telling you that $request does not have a property named 'newsId'. The place where $request is populated is in the 2nd line, which comes from the $data in your 'php://input' file. So the input file is missing something. Depending on where it's failing, it's either a "UPDATE_NEWS" action or a "DELETE_NEWS" action.
At this point, I have no idea what you are trying to do. The only thing your code does that matches anything you've said is that it's in a Sub rather than an event procedure. There's nothing about protecting the worksheet or letting particular users have different options than other users.
It is not clear what you're trying to accomplish. It seems like you're trying to lock either some or all of the cells in the worksheet if the worksheet is not protected. And to do it in a Sub that is not an event handler Sub. Is that correct? If not, please provide a complete and detailed explanation of what you're trying to do.
Go to the Disk Management control panel (right click on start menu and search for disk management). It might need to be formatted and/or have a drive letter assigned.
Is "frmProudctM" a misspelling in the With statement? Maybe should be frmProductM (or whatever, can't tell from just this snippet).
Last Updated 1 Jan 1900
All Rights Reserved.