|
If you're using Excel 2007 files (*.xlsx ), any of the following will work:
If you need to support Excel 2003 files (*.xls ) as well, you'll need something like NPOI[^].
(There are also commercial toolkits around, but I've never seen the need for them when all of the above libraries are free and open-source.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You need to learn program profiling: Profiling (computer programming) - Wikipedia[^]
With a profiler program, you will spot the parts where the computer spend time.
If you don't have such tool, as simple benchmark and runs with changing some values (number of rows and columns) will give you hints.
You will discover that runtime is linear with row numbers, but that it is not with column numbers.
You will see that runtime turn ugly as columns increase. The problem comes from the way you build the string inside the column loop.
Think about your code, and about the reason you do what you do, is it really needed?
Search if there is another way to things.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
i have one program.in that n number of boxes.need to arrange the box according to the size.first biggest box is the outer box.that we need to place in (0,0) position.Rest all the boxes i need to arrange inside the box from biggest to smallest.biggest in the bottom.smallest in the top.if the outer box height is more than the inner box arrange near to the bigger box of the bottom.
can anybody help me
|
|
|
|
|
Sounds very much like a homework assignment to me. We don't do homework for you - it's set for a reason, to test what you know, not what a random bunch of strangers on the Internet know. What have you tried so far? What code do you have?
This space for rent
|
|
|
|
|
I've seen a post from Luc Pattyn describing it as a "knapsack problem". Found the thread here[^], and contains a link to wikipedia detailing different sacks and some pseudo-code.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, I am processing Excel files, I need to convert the .xls files that are 32 bit into 64 bit .xlsx files and supply them to the SSIS Packages for Processing. I need to write it in .Net code, can anybody please help me in this regards if its possible or not? I am also searching on google, if you can help me it will save me, as it is needed little urgently. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
They're not 32-/64-bit files. The .xls files are old-style Excel 2003 files, and the .xlsx files are the newer Excel 2007 / OpenXML files.
If you're writing an interactive desktop application which will be run on a computer with Office 2007 or later installed, you could use Interop to convert the files:
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(sourceFilePath);
wb.SaveAs(Filename: destinationFilePath, FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
wb.Close();
app.Quit();
Otherwise, you'll need to use a library which supports both formats - for example, NPOI[^]. It's not trivial, but this StackOverflow answer[^] has an example.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I am getting an issue in my Application that's reading Excel files and Oracle Database, it was working before it started giving problems suddenly.
I am thinking probably the drivers are the issue, but want to know which drivers are installed on the machine.
Can somebody please let me know how can I find the version and mode (like 32 or 64 bit) Oracle and Office Drivers installed on my machine. I am also searching on the google, but if you can help me earlier than that, it would be a great help my friends. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
I can see you, sitting on the couch, feet on the coffee table, typing this on your phone, while watching tv...
It took more effort to type this message than to go into the Control Panel; Admin; etc.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It is possible that the OP was not expressing himself perfectly! If it was, indeed, the software on his machine (i.e. the one he was sitting in front of) about which he was asking, your response was fairly appropriate. I suspect, however that he is trying more generally to identify the installed Oracle and Office versions on a user's system from within a running Application. I haven't looked into this for Oracle, but I have for Office, and it is highly non-trivial, since Microsoft doesn't keep comprehensible Office version information in any standard location. If that is what he needs, I suggest that he posts back to confirm this, and I will try to offer some suggestions.
|
|
|
|
|
Dim Number1 As String = "2812"
Dim Str, strTemp, strReturn As String
Dim x As Long
Str = "ATDT" & Number1 & "R"
For x = 1 To Len(Str)
strTemp = Hex$(Asc(Mid$(Str, x, 1)))
If Len(strTemp) = 1 Then strTemp = "0" & strTemp & ","
strReturn = strReturn & Space$(1) + "&H" & strTemp
Next x
strReturn = stReturn & " &HD"
Dim Num as integer = Convert.ToInt32(strReturn)
buffer = {Num}
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
Threading.Thread.Sleep(500)
buffer = {&H41, &H54, &H44, &H54, &H32, &H38, &H31, &H32, &H52, &HD}
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
Threading.Thread.Sleep(500)
Next x
modified 1-Sep-17 8:09am.
|
|
|
|
|
Problem 1:
Convert.ToInt32 expects a string containing a single numeric value, and returns a single Integer value.
You are trying to convert a string containing multiple numeric values, and expecting an array of Integer values.
You would need to split the string, and convert each part separately.
Problem 2:
Convert.ToInt32(ByVal value As String)[^] does not allow you to use a Hex prefix. Neither the VB prefix (&H ) nor the C# prefix (0x ) will work.
Instead, you need to remove the prefix and call the overload which accepts the base you want to convert from:
Convert.ToInt32(ByVal value As String, ByVal fromBase As Integer)[^]
(NB: The C# prefix would work with this overload, but the VB.NET prefix won't.)
Dim parts() As String = strReturn.Split(" "c)
Dim buffer() As Integer = Array.ConvertAll(parts, Function(p) Convert.ToInt32(p.Substring(2), 16))
Problem 3:
You're converting the values to Integer , but Write[^] expects an array of Byte values.
It would be much simpler to use the Encoding[^] class to convert the string to a series of bytes:
Dim Number1 As String = "2812"
Dim Str As String = "ATDT" & Number1 & "R" & Chr(&HD)
Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(Str)
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 19-Sep-17 7:38am.
|
|
|
|
|
Thanks, I guess I was just over complicating it.
|
|
|
|
|
Richard Deeming wrote: Convert.ToInt32 does not allow you to use a Hex prefix. Neither the VB prefix (&H ) nor the C# prefix (0x ) will work.
Huh?
"If fromBase is 16, you can prefix the number specified by the value parameter with "0x" or "0X"."
Convert.ToInt32 Method (String, Int32) (System)[^]
|
|
|
|
|
Only on the overload that takes the "from base" parameter. That's not the overload the OP was calling.
Convert.ToInt32("2A", 16)
Convert.ToInt32("0x2A", 16)
Convert.ToInt32("&H2A", 16)
Convert.ToInt32("0x2A")
Convert.ToInt32("&H2A")
I'll edit the message to clarify.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Getting this error.
System.AccessViolationException was unhandled
Message: An unhandled exception of type 'System.AccessViolationException' occurred in AxInterop.ShockwaveFlashObjects.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
When I have Adobe Flash security updates installed.
Using this code
Flash.Movie("movie.swf")
Flash.Play
Then
Flash.LoadMovie(1, "crash.swf") 'Crashes when Adobe Flash is updated, doesn't allow top layer SWF to interact with Movie/base.
To load multiple SWF layers at same time crashes. I'm guessing the security update did something so you can't write layered SWF code to the original SWF's memory. I don't know why this is, but is there any fix or will there be one? This has been like this for about a year now, and it doesn't seem like it'll be addressed.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ShockwaveFlashObjects.IShockwaveFlash.LoadMovie(Int32 layer, String url)
at AxShockwaveFlashObjects.AxShockwaveFlash.LoadMovie(Int32 layer, String url)
at AEDab.Form1.ListBox1_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\UDA\Documents\Visual Studio 2013\Projects\uh\uh\Form1.vb:line 77
at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
You probably need to report this to Adobe and check with them for a fix.
|
|
|
|
|
I've tried but I've never gotten a response. This has been over a year so far, multiple attempts to contact but all have been ignored.
|
|
|
|
|
Hi,
I am getting the following error no matter what path I am giving for this file to load into a Table in the Database from Excel using Jet Engine
The path I have tried are
1. I kept the file on my local machine to run the Package from my Local machine, it said invalid Path (C:\Users\aaleem01\Desktop\Project Documents\Tucker Package\Daily Facets Report 8.21.17.xls)
2. I kept the shared drive/folder, still it gave me in valid file path (Z:\FileWatcher\Daily Facets Report 8.21.17.xls)
3. Then I dropped the file on the Server where Sql Server instance is running and used that path in creating the Connection string for Excel, still it gave me the same error
Can anybody tell me what could be wrong in my file Path, I am trying to execute a Script Task in which I load data from Excel file into a Sql Server Table.
Here is how my Code looks like:
string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Dts.Variables["ExcelFullPath"].Value + ";Extended Properties=Text;";
string sqlConnectionString = "Data Source=" + Dts.Variables["ServerName"].Value + ";Initial Catalog="
+ Dts.Variables["Saw_Raw_DatabaseName"].Value
+ ";Integrated Security=SSPI;";
using (OleDbConnection conn = new OleDbConnection(excelConnectionString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
using (OleDbCommand oleCmd = new OleDbCommand("select * from [" + Dts.Variables["SheetName"].Value + "$]", conn))
{
using (OleDbDataReader reader = oleCmd.ExecuteReader())
{
InsertData(Dts.Variables["TableName"].Value.ToString(), reader, sqlConnectionString);
}
if (conn.State != ConnectionState.Closed)
conn.Close();
}
}
The exact error is as follows:
'C:\SSIS Packages\TempFiles\Daily Facets Report 8.21.17.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Any type of help can be very helpful like Code snippet, a link or a suggestion. Thanks in advance friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 29-Aug-17 19:48pm.
|
|
|
|
|
|
It is fairly clear that the path in the error message is not the same as either of the locations where that file is actually stored.
I notice also that you are using Extended Properties=Text; to read an Excel workbook. That is not correct, you should use Extended Properties=Excel 8.0; . See Working with MS Excel(xls / xlsx) Using MDAC and Oledb[^].
|
|
|
|
|
How can i show a pie chart crystal report showing monthly auto sales for all models ( crosswind, d-max, alterra, Mu-X, N-Series, F-Series)?
|
|
|
|
|
|
Hi,
I am starting a process using P/Invoke of
CreateProcessWithTokenW
Eyerthing works fine, e.g. when I run a simple command like "ipconfig > test.log" then the file contains the output of the file. Process Explorer also tells me that the process runs as the user I impersonated to...
When I start a GUI application, however, I run into a strange problem: The process starts without error and the icon of the process pops up in the taskbar (e.g. the notepad icon), but I cannot "look at the GUI". Its a bit hard to explain, but I can click on the taskbar icon and a frame of the Window appears, but is has no "contents". I can click on the close icon and the windows closes.
Please refer to this screenshot. It also shows that this is not a "move to screen" issue
ScreenShot
I'd be happy for all sorts of advice.
Cheers,
Guido
|
|
|
|
|