|
Do you ever find that someone unplugged your brain while you were asleep?
TBH I missed the two key words.
|
|
|
|
|
THe only purpose in me doing this is to get my data in to sql so that I can start cleaning the old data up (It is a mess), and making the needed changes. The only time I would use this is a few times when I need to reupload data.
|
|
|
|
|
Michael Hinkle wrote: web development
You won't be able to use Excel automation to do this:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
Instead, use a library which supports reading Excel files without having Excel installed.
For Excel 2007 files (*.xlsx) , any of the following should work:
If you need to support old-format files (*.xls) , then you can use NPOI[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Assuming SQL means SQl server the why not do the clean up in SSMS. My standard method was:
Import the data manually into SQL Server. I would load the data into a new table accepting whatever garbage is in the excel file. All data should be converted to strings on the way in.
Create and empty destination table matching your final destination (this is so you can repeat the process)
Write a stored procedure that:
loops each column and cleans and formats the data as required and inserts it into the temp table.
When you are confident the process works then change the destination to the final destination table.
If this works consistently between loads you can then turns the entire process into a Job which can then be launched by your application.
This method does require reasonable T-SQL skills but would also be an excellent learning exercise.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Here is something that I use in my web app ...
1) Define a connection string pointing to the Excel file
String.Format("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = {0}; Extended Properties='Excel 12.0; HDR=Yes; IMEX=1;'", sFilename)
2) You can access some schema information from the Excel doc like this ...
DTschema = dbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
3) Then get to the actual data in the spreadsheet like this ...
Using dbCmd As New OleDbCommand("SELECT * FROM [" & sSheet & "]", dbConn)
Using dbAdapter As New OleDbDataAdapter(dbCmd)
dbAdapter.Fill(DT)
End Using
It may not be pretty, but you get the data from the spreadsheet into a datatable which can then be bound to a Gridview.
See if it works for you.
|
|
|
|
|
|
Let say I have an existing MVC (Core/.NET5) app.. and I want to add a few new pages build with Blazor..
How will I proceed?
I am having a hard time making it work, or finding relevant links..
|
|
|
|
|
|
At work I am asked to do integrate our web app with some 3rd party authenticator app, say Microsoft Authenticator (they are really thinking Twilio, since MS Auth App seem expensive to use), so that some (specific) (web) page are protected with an additional level of security that would require to enter the web code from the authenticator app (not really standard MFA usage, anyway..)
At first sight this look impossible... However I noticed that in both MS and Google Authenticator there is a list of app that can be registered, not all from either MS or google... So there might be a way to use "some" well known 3rd party authenticator app with your login... Any link please?
|
|
|
|
|
Assuming you're using the standard code for generating the authenticator PIN, almost any app can be used. For example, I use Authy[^] so I can access the same set of codes on all of my computers and my mobile phone.
There are various references on how to generate the PIN from your own code. For example:
Implementing Two Factor Authentication in ASP.NET MVC with Google Authenticator[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks for the tip! going to investigate that!
|
|
|
|
|
Hello. I am at my wits' end trying to make this work. I have developed a website in Dreamweaver and it displays correctly. I have used custom fonts that have displayed correctly. When previewing it from Dreamweaver in Firefox, Chrome and Opera it all displays fine. When I upload to the remote server the website displays fine in Firefox but not in Chrome and Opera. I am not sure what is happening and I am stuck as I need it to display properly. Any guidance would be massively appreciated. Kind Regards
The website is siconlightning.solutions
🤯
|
|
|
|
|
Use the browser's developer tools (F12) to see if a file is not getting loaded or if css is not getting applied.
|
|
|
|
|
Can anyone help me know how to filter an array of objects based on another object with conditions.
const arrayToFilter= [ {
name: 'Arlin Schistl',
screen_name: 'aschistl1c',
followers_count: 101,
following_count: 657,
location: 'Indonesia',
verified: true,
},
{
name: 'Henka Perren',
screen_name: 'hperren1d',
followers_count: 170,
following_count: 422,
location: 'Mexico',
verified: true, },
{
name: 'Mei Raja',
screen_name: 'hperren1d',
followers_count: 17330,
following_count: 42,
location: 'Porur',
verified: false, }
]
Filter conditions :
const conditions=[
{
id: 'name',
operator: 'CONTAINS'
value: 'Bob',
},
{
condition:'OR',
id: 'followers_count',
operator: 'GTE'
value: 200,
},
{
condition:'AND',
id: 'following_count',
operator: 'LTE'
value: 10,
},
{
condition:'AND',
id: 'followers_count',
operator: 'GTE'
value: 150,
}
]
Please let me know what will be the optimized code for this. Thanks in advance!
|
|
|
|
|
Question: Are the criteria sequential or do they obey a hierarchy of operator? That is, using your example, do you want
( (name CONTAINS bob)
OR ( (followers_count GTE 200)
AND ( (following_count LTE 10)
AND (followers_count GTE 150)
) ) ) or, perhaps,
( ( (name CONTAINS bob)
OR (followers_count GTE 200)
)
AND (following_count LTE 10)
AND (followers_count GTE 150)
)
|
|
|
|
|
I wrote this PHP 7.14.4 class to represent an object of Keys and Values, made up of Key Value. It uses IteratorIterator, which I have found to contains about 15 useful methods to do things like count(), append(), move() and uasort(). I wrote this sort of piecing together some concepts, and thought it would be a nice method to have in my swiss army knife.
I get this error message, and I understand what it says, and I have 1/2 a clue on how to fix it, but I can't visualize how to return a new instance of KeyValue.
Fatal error: Uncaught TypeError: Return value of KeyValues::uaSort() must be an instance of KeyValues, none returned in C:\App\Dev\PCAD\models\keyValue.model.php:52 Stack trace: #0 C:\App\Dev\PCAD\api\prices\priceSetUpdate.api.php(61): KeyValues->uaSort() #1 {main} thrown in C:\App\Dev\PCAD\models\keyValue.model.php on line 52
I called the method like this below ....
I'm surprised PHP didn't complain about my merge method concept that I wrote. I included the extra code so you can get an idea of what I'm doing and how I use it.
foreach ($partKeyValues as $partKeyValue) {
$referenceId = $partKeyValue->getValue();
$taskVersions = TaskVersionsRepository::getTaskVersionsByReferenceId($referenceId);
$taskKeyValues->merge($taskVersions);
}
$taskKeyValues->uaSort();
class KeyValues extends IteratorIterator {
public function __construct(KeyValues ...$keyValues)
{
parent::__construct(new ArrayIterator($keyValues));
}
public function count() : int
{
return $this->getInnerIterator()->count();
}
public function merge(KeyValues $keyValues)
{
foreach ($keyValues as $keyValue) {
$this->getInnerIterator()->append($keyValue);
}
}
public function uaSort(): KeyValues {
$this->getInnerIterator()->uasort(
function(KeyValue $a, KeyValue $b) {
return $a->getValue() <=> $b->getValue();
}
);
}
class KeyValue {
private $key;
private $value;
public function __construct()
{
}
public function getKey() { return $this->key; }
public function setKey($key) { $this->key = $key; }
public function getValue() { return $this->value; }
public function setValue($value) { $this->value = $value; }
}
So your probably wondering what the story here is on me working with PHP 7.4. I decided to help this company that got burned on a PHP 4.7 project last worked on in 2011, in which the designers and coders lost control of proper programming practices, going completely crazy with PHP which is typical. They put the presentation HTML in classes, and business logic in the presentation layer. Then their IT guy thought he could be a programmer and started working on it making it worst, because he thought the existing code was proper programming practices.
Whats weird, is that the IT company hosting the App suggested to the customer that they should upgrade from PHP 4.73 to PHP 8 to plug the security holes, thinking that the upgrade was like upgrading to Windows 10. So I went along with it, and began to realize that upgrading to PHP 8 was more like a quest to stop writing bad procedural code and embrace the power of object orientated programming in PHP 8. My goal is to get this right, do a great job, and not shame myself with what I deliver.
I'm starting to like PHP, and see why so many organizations use it to this date. This really hasn't been a journey of learning how to code in PHP, but more like a proper lesson in how to implement proper design principles for me. Perhaps this finally elevates me to a higher level of thinking.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I ended up with 2 methods that I couldn't figure out yesterday, the other being array_intersect which requires an array and not an object. So after about an hour of research on arrays and objects, I did some converting and ended up with this today, which worked after running several tests.
public function intersect(KeyValues ...$keyValues): KeyValues {
$a = iterator_to_array($this->traversable($this->getInnerIterator()));
$b = iterator_to_array($this->traversable($keyValues));
$arrayItems = array_intersect($a, $b);
$newKeyValues = new KeyValues();
foreach ($arrayItems as $arrayItem) {
$newKeyValue = new KeyValue();
$newKeyValue->setKey($arrayItem[0]);
$newKeyValue->setValue($arrayItem[1]);
$newKeyValues->add($newKeyValue);
}
return $newKeyValues;
}
Which segways to this. I didn't need uasort, and resorted back to sort. I really just want to reference the original object and sort it. So I'm going to have to give this more thought. In other words just sort the getInnerIterator().
Called it like this
$taskKeyValues = $taskKeyValues->sort();
public function sort(): KeyValues {
$arrayItems = iterator_to_array($this->traversable($this->getInnerIterator()));
sort($arrayItems);
$newKeyValues = new KeyValues();
foreach ($arrayItems as $arrayItem) {
$newKeyValue = new KeyValue();
$newKeyValue->setKey($arrayItem[0]);
$newKeyValue->setValue($arrayItem[1]);
$newKeyValues->add($newKeyValue);
}
return $newKeyValues;
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
How to find a word in the project code in phpstorm?
|
|
|
|
|
|
Hello All,
I want to develop Master Details CRUD option. I have seen lots of examples in which developed using GRID but my requirement is different than this.
Let me explain with an example
-------Master Part-------
Order No__________ Order Date___________
Customer_______________
----------Details Part------------
ProductName _____{Selection}______ Rate______ Qty____ [Add]
-----------{GRID}--------------
Product1 20.00 1 [EDIT] [DELETE]
Product2 50.00 1 [EDIT] [DELETE]
[SAVE][CANCEL]
Please check this -> Example screen
modified 14-Apr-21 3:04am.
|
|
|
|
|
|
Hello
Thanks for reply.
Every application has own problems and benefits.
|
|
|
|
|
You product selection line is not part of the detail and can be placed in the master area or as a separate area altogether, it does not participate in the master detail structure but adds to the detail.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
My Table Stucture look like
OrderId int
OrderNo string
CustomerName string
AddDate DateTime
OrderDtlId int
OrderId int(FK from OrderMaster)
ProductId int(FK from ProductMaster)
Qty decimal
Rate decimal
|
|
|
|
|
Your table structure is correct. You need to add a detail item when the user clicks add taking the ProductId from the user selection. This needs to be done in code, not in the UI control.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|